http://acm.hdu.edu.cn/showproblem.php?pid=5373
YY题,模拟下计算过程就好了,计算中并不要保存实际数(这个数会非常大),只要保存到目前为止的数字位上的和 与 奇偶位上的差即可
#pragma comment(linker, "/STACK:1677721600")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstdarg>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define inf (-((LL)1<<40))
#define root 1, 1, n
#define lc (k << 1)
#define rc (k << 1 | 1)
#define middle ((L + R) >> 1)
#define lson k<<1, L, (L + R)>>1
#define rson k<<1|1, ((L + R)>>1) + 1, R
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define mem(a, b) memset(a, b, sizeof(a))
#define FIN freopen("in.txt", "r", stdin)
#define FOUT freopen("out.txt", "w", stdout)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define dec(i, a, b) for(int i = a; i >= b; i --) //typedef __int64 LL;
typedef long long LL;
typedef pair<int, int> Pair;
const int MAXN = + ;
const int MAXM = ;
const double eps = 1e-10;
LL MOD = ; int n, t; //将n拆开,数字和加到sum中,奇偶差加到dif中,符号保存在f中
void calc_dif(int n, int &f, int &dif, int &sum) {
int d = , s = , pf = f;
while(n) {
s += n % ;
d += n % * f;
f = -f;
n /= ;
}
if(f == pf) d *= -;
sum += s;
dif += d;
} int main()
{
#ifndef ONLINE_JUDGE
FIN;
// FOUT;
#endif
int cas = ;
while(cin >> n >> t && (n != -)) {
int f = , dif = , sum = ;
calc_dif(n, f, dif, sum);
while(t--) calc_dif(sum, f, dif, sum);
printf("Case #%d: %s\n", ++cas, dif % ? "No" : "Yes");
}
return ;
}