A - Sequence and Sequence ZOJ - 4058
B - Kawa Exam ZOJ - 4059
C - Flippy Sequence ZOJ - 4060
D - Magic Multiplication ZOJ - 4061
E - Plants vs. Zombies ZOJ - 4062
F - Tournament ZOJ - 4063
G - Repair the Artwork ZOJ - 4064
H - Mirror ZOJ - 4065
I - Soldier Game ZOJ - 4066
J - Books ZOJ - 4067
K - Airdrop ZOJ - 4068
L - Sub-cycle Graph ZOJ - 4069
M - Function and Function ZOJ - 4070
打表找規律類型,單個數K次方之間有啥關係,或者是找到變成0的情況.
#include<queue>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<set>
using namespace std;
const int maxn = 1e4+3;
typedef long long LL;
#define INF 0x3f3f3f3f
const int MOD = 9973;
int val[12] = {1,0,0,0,1,0,1,0,2,1};
int change(int a)
{
int num = 0;
if(a == 0)
return val[a];
while(a)
{
num += val[a%10];
a/=10;
}
return num;
}
int main()
{
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int n;
while(cin>>n && n)
{
int a,b;
for(int i=0;i<n;i++)
{
cin>>a>>b;
while(b)
{
--b;
a = change(a);
if(a == 0)
break;
}
if(b == 0)
cout<<a<<'\n';
else if(b&1)
cout<<1<<'\n';
else cout<<0<<'\n';
}
}
return 0;
}