https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1770
中文题意。
从左到右模拟,试了几个数,发现最多后面两个数和最前面一个数会变化,其他都不会变化。。并且最多只会增加一位。
#include <bits/stdc++.h>
using namespace std;
/*模拟题。
开始打了多少个看规律。
发现最多是 倒数第一个和倒数第二个 正数第一个不会变。
其他的都是一样的。
然后写,写错了。。
*/
bool vis[11];
int num[11];
int a,b,c,d;
int main()
{ int t;
scanf("%d",&t);
while(t--){
memset(num,0,sizeof(num));
memset(vis,false,sizeof(vis));
scanf("%d%d%d%d",&a,&b,&c,&d);
if(a*b<=9){
num[a*b]=d;
printf("%d\n",num[c]);
}
else{
int add=(a*b)/10;
int pre=(a*b)%10;
num[pre]++;
d--;
while(d){
int ori=(a*b+add)%10;
add=(a*b+add)/10;
if(num[ori]){
num[ori]+=d;
break;
}
else{
num[ori]++;
}
d--;
}
num[add]++;
printf("%d\n",num[c]);
}
}
return 0;
}