临时代码。
zoj 3673
1 /** 2 6700417 3 **/ 4 #include<iostream> 5 #include<stdio.h> 6 #include<cstring> 7 #include<cstdlib> 8 #include<algorithm> 9 using namespace std; 10 11 typedef unsigned long long LL; 12 13 LL Euler(LL n) 14 { 15 LL i,temp=0; 16 for(i=2;i*i<=n;i++) 17 { 18 if(n%i==0) 19 { 20 while(n%i==0) 21 n=n/i; 22 if(i>temp) temp = i; 23 } 24 } 25 if(n>temp) temp = n; 26 printf("%llu\n",temp); 27 } 28 int main() 29 { 30 Euler(18446744073709551615); 31 return 0; 32 }
hdu Bell
1 /** 2 3 31 37 41 43 47 4 5 **/ 6 #include<iostream> 7 #include<stdio.h> 8 #include<cstdlib> 9 #include<cstring> 10 using namespace std; 11 typedef __int64 LL; 12 13 LL i,num=0; 14 if(n!=1)printf("%I64d 1 \n",n); 15 } 16 int main() 17 { 18 return 0; 19 }
1 #include<iostream> 2 #include<stdio.h> 3 #include<cstring> 4 #include<cstdlib> 5 using namespace std; 6 typedef __int64 LL; 7 8 LL p ; 9 struct Matrix 10 { 11 LL mat[3][3]; 12 void init() 13 { 14 mat[1][1]=1;mat[1][2]=1; 15 mat[2][1]=1;mat[2][2]=0; 16 } 17 void mem() 18 { 19 mat[1][1]=1;mat[1][2]=0; 20 mat[2][1]=0;mat[2][2]=1; 21 } 22 }; 23 Matrix multiply(Matrix cur,Matrix ans) 24 { 25 Matrix now; 26 memset(now.mat,0,sizeof(now.mat)); 27 int i,j,k; 28 for(i=1;i<=2;i++) 29 { 30 for(k=1;k<=2;k++) 31 { 32 if(cur.mat[i][k]==0)continue; 33 for(j=1;j<=2;j++) 34 { 35 if(ans.mat[k][j]==0)continue; 36 now.mat[i][j] +=cur.mat[i][k]*ans.mat[k][j]; 37 now.mat[i][j]%=p; 38 } 39 } 40 } 41 return now; 42 } 43 Matrix add(Matrix cur,Matrix ans) 44 { 45 Matrix now; 46 memset(now.mat,0,sizeof(now.mat)); 47 int i,j; 48 for(i=1;i<=2;i++) 49 { 50 for(j=1;j<=2;j++) 51 { 52 now.mat[i][j] = cur.mat[i][j]+ans.mat[i][j]; 53 now.mat[i][j]% =p; 54 } 55 } 56 return now; 57 } 58 Matrix pow_mod2(Matrix cur,LL n) 59 { 60 LL dp[64],len=0,i; 61 Matrix tp1,tp2=cur,ret; 62 ret.mem(); 63 while(n) 64 { 65 dp[++len]=(n&1); 66 n=n>>1; 67 } 68 for(i=len-1;i>=1;i--) 69 { 70 tp1=multiply(tp1,add(tp2,ret)); 71 tp2=multiply(tp2,tp2); 72 if(dp[i]==1) 73 { 74 tp2=multiply(tp2,cur); 75 tp1=add(tp2,tp1); 76 } 77 } 78 return tp1; 79 } 80 Matrix pow_mod(Matrix cur,LL n) 81 { 82 Matrix now; 83 now.mem(); 84 while(n) 85 { 86 if(n&1) now=multiply(now,cur); 87 n=n>>1; 88 cur=multiply(cur,cur); 89 } 90 return now; 91 } 92 int main() 93 { 94 LL k,b,n; 95 while(scanf("%I64d%I64d%I64d%I64d",&k,&b,&n,&p)>0) 96 { 97 Matrix hxl; 98 hxl.init(); 99 Matrix tom = pow_mod(hxl,b); 100 Matrix qq = pow_mod2(hxl,n); 101 tom = multiply(tom,qq); 102 } 103 return 0; 104 }
浙公网安备 33010602011771号