标签:des style blog class code java
Time Limit: 1000/1000 MS
(Java/Others) Memory Limit: 131072/131072 K
(Java/Others)
Total Submission(s): 3628 Accepted
Submission(s): 1186
1 /**开开心心找规律**/ 2 3 #include<iostream> 4 #include<stdio.h> 5 #include<cstdlib> 6 #include<cstring> 7 using namespace std; 8 typedef __int64 LL; 9 10 void solve(LL n,LL p) 11 { 12 LL i,j=1,s=1; 13 for(i=1;i<=n;i++) 14 { 15 j=(j*i)%p; 16 s=(s+j)%p; 17 } 18 printf("%I64d\n",s); 19 } 20 int main() 21 { 22 LL T; 23 char a[10000]; 24 LL i,n,m; 25 scanf("%I64d",&T); 26 while(T--) 27 { 28 scanf("%s%I64d",a,&n); 29 if(n==1){ 30 printf("0\n"); 31 continue; 32 } 33 for(i=0,m=0;a[i]!=‘\0‘;i++) 34 { 35 m=m*10+a[i]-‘0‘; 36 if(m>=n) 37 { 38 m=n; 39 break; 40 } 41 } 42 solve(m,n); 43 } 44 return 0; 45 }
标签:des style blog class code java
原文地址:http://www.cnblogs.com/tom987690183/p/3714992.html