Gym 101194A / UVALive 7897 - Number Theory Problem - [找规律水题][2016 EC-Final Problem A]

题目链接:

http://codeforces.com/gym/101194/attachments

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5919

 

题意:

给出正整数 $N(1 \le N \le 10^5)$,询问对于正整数 $k$,有多少个小于 $2^N$ 的 $2^k-1$ 是 $7$ 的整数倍。

 

题解:

$k$ 必然是 $3$ 的正整数倍。

 

AC代码:

#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
    int T;
    cin>>T;
    for(int kase=1;kase<=T;kase++)
    {
        scanf("%d",&n);
        n-=n%3;
        printf("Case #%d: %d\n",kase,(n-3)/3+1);
    }
}

 

posted @ 2018-11-03 20:15  Dilthey  阅读(273)  评论(0编辑  收藏  举报