zoukankan      html  css  js  c++  java
  • Number Theory Problem(The 2016 ACM-ICPC Asia China-Final Contest 找规律)

    题目:

    Mr. Panda is one of the top specialists on number theory all over the world. Now Mr. Panda is investigating the property of the powers of 2. Since 7 is the lucky number of Mr. Panda, he is always interested in the number that is a multiple of 7. However, we know that there is no power of 2 that is a multiple of 7, but a power of 2 subtracted by one can be a multiple of 7. Mr. Panda wants to know how many positive integers less than 2n in the form of 2k-1 (k is a positive integer) that is divisible by 7. N is a positive interger given by Mr Panda.

    Input:

    The first line of the input gives the number of test cases, T. T test cases follow. Each test case contains only one positive interger N.

    output:

    For each test case, output one line containing “Case #x: y”, where x is the test case number (starting from 1) and y is the answer.

    题意:给出一个数N,找有多少个数,这些数的大小小于2N,且这些数符合2k-1的形式。

    思路:把100以内的这种数和对应的N输出出来,会发现个数与N是成三倍的关系的。

    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <algorithm>
    #include <queue>
    #include <map>
    #include <set>
    #include <vector>
    #include <iomanip>
    using namespace std;
    vector<long double> v;
    
    int read()
    {
        int res = 0;
        char op = getchar();
        if(op>='0' && op<='9')
        {
            res = op-'0';
            op = getchar();
        }
        while(op>='0'&&op<='9')
        {
            res = res*10+op-'0';
            op = getchar();
        }
        return res;
    }
    int main()
    {
        int T,n,cnt=1;
        T = read();
        while(T--)
        {
            int n;
            n = read();
            printf("Case #%d: %d
    ",cnt++,n/3);
        }
        return 0;
    }
    View Code
  • 相关阅读:
    在Centos7下源代码安装配置Nginx
    mysql5.7.21源码安装
    数据库设计三大范式
    电商项目中使用Redis实现秒杀功能
    PHP和Redis实现在高并发下的抢购及秒杀功能示例详解
    PHP面向对象(抽象类与抽象方法、接口的实现)
    php面向对象 封装继承多态 接口、重载、抽象类、最终类总结
    利用VHD虚拟文件加密自己的个人信息
    Chrome常用快捷键
    stl本子
  • 原文地址:https://www.cnblogs.com/sykline/p/9747475.html
Copyright © 2011-2022 走看看