Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1076 Accepted Submission(s): 510
#include <stdio.h> #include <string.h> #include <algorithm> #include <iostream> #include <stdlib.h> #include <math.h> using namespace std; typedef long long LL; LL pow_mod(LL a,LL n,LL mod){ LL ans = 1; while(n){ if(n&1) ans = ans*a%mod; a = a*a%mod; n>>=1; } return ans; } int main() { LL x,m,k,c; int tcase; scanf("%d",&tcase); int t =1; while(tcase--){ cin>>x>>m>>k>>c; printf("Case #%d:\n",t++); LL mod = 9*k; LL ans = ((pow_mod(10,m,mod)-1)*x%mod+mod)%mod; if(ans==9*c%mod){ printf("Yes\n"); }else printf("No\n"); } return 0; }
原文:http://www.cnblogs.com/liyinggang/p/5536007.html