标签:
姿势就是力量啊!
第一次意识到long long 比 int要慢很多。当时想到了各种优化仍然TLE,最后也没A出来,就是用了long long
1 #include <cstdio> 2 #include <algorithm> 3 #include <cstring> 4 #include <ctype.h> 5 #include <cstdlib> 6 #include <stack> 7 #include <set> 8 #include <map> 9 #include <queue> 10 #include <string> 11 12 using namespace std; 13 14 int N,T; 15 int len = 0; 16 17 int mem,ans; 18 19 void solve(int n) 20 { 21 int li=0,nn = n; 22 do{ 23 mem += n%10; 24 n/=10; 25 li++; 26 }while(n); 27 28 int t = li; 29 30 while(li--) 31 { 32 int a = (nn%10); 33 int b = ((((len+li) % 2) == 1) ? 10 : 1); 34 //printf("%d %d\n",nn%10,len+li); 35 nn/=10; 36 ans += (a*b%11); 37 ans %= 11; 38 } 39 len += t; 40 } 41 42 int main() 43 { 44 int kase = 0; 45 46 while(~scanf("%d%d",&N,&T) && N != -1 && T != -1) 47 { 48 kase ++; 49 50 len = 0; 51 mem = 0; 52 ans = 0; 53 54 solve(N); 55 while(T--) solve(mem); 56 ans %= 11; 57 58 if(ans == 0) printf("Case #%d: Yes\n",kase); 59 else printf("Case #%d: No\n",kase); 60 } 61 }
标签:
原文地址:http://www.cnblogs.com/helica/p/4729834.html