NYOJ 88

View Code
 1 /*
2 推出:f[n]=2*f[n-1]+1;
3 f[1]=1;
4 可得:f[n]=2^n-1;
5 */
6 #include<iostream>
7 #include<cstdio>
8 using namespace std;
9
10 const int x=1000000;
11 void gao(int n)
12 {
13 long long s=1,t=2;//注意范围
14 for(;n;n>>=1,t=(t%x)*(t%x),t%=x)
15 if(n&1)
16 {
17 s%=x;
18 s*=t;
19 s%=x;
20 }
21 printf("%lld\n",s-1);
22 }
23
24 int main()
25 {
26 int t,n;
27 scanf("%d",&t);
28 while(t--)
29 {
30 scanf("%d",&n);
31 gao(n);
32 }
33
34 system("pause");
35 return 0;
36 }

 

posted @ 2012-02-21 12:56  知行执行  阅读(140)  评论(0编辑  收藏  举报