现在的位置: 首页 > 综合 > 正文

集训总结—第一天

2015年05月31日 ⁄ 综合 ⁄ 共 653字 ⁄ 字号 评论关闭

集训总结---第一天:

字典树《《  题目链接:点击打开链接

286 290,511,163,685.

欧拉回路《《   

HDOJ---1395

F - 2^x mod n = 1.

Time Limit:1000MS    MemoryLimit:32768KB    64bit
IO Format:
%I64d & %I64u

Give a number n, find the minimumx(x>0) that satisfies 2^x mod n = 1.

Input.

One positive integer on each line, thevalue of n.

Output.

If the minimum x exists, print a line with2^x mod n = 1.

Print 2^? mod n = 1 otherwise.

You should replace x and n with specific numbers.

Sample Input

 2

5

 

Sample Output

 2^? mod 2 =1

2^4 mod 5 = 1

考点:

大数枚举。

#include<cstdio>
#include<cstring>
int main()

{

 int T;

while(scanf("%d",&T)!=EOF)

    {

        int i,nib = 2;

           bool flag = 0;

        for(i = 1;i<=T;i++)

        {

            nib = nib%T;

            if(nib==1)

            {

                flag = 1;

                break;

            }

            nib*=2;

        }

        if(flag)

        printf("2^%d mod %d = 1\n",i,T);

        else

        printf("2^? mod %d = 1\n",T);

    }

    return 0;

}

抱歉!评论已关闭.