aaaaaa*b = 111111*a*b
然后找找规律就好了
比如
11111*9=99999
11111*18=199998
11111*48=533328
手动模拟下乘法就能看出来了
#include <bits/stdc++.h>
using namespace std;
int record[10];
int main()
{
// freopen("51nod_Problem_1770_Test_20_In.txt","r",stdin);
// freopen("out.txt","w",stdout);
ios::sync_with_stdio(false);
int T,a,b,d,n;
cin >> T;
while(T--)
{
memset(record,0,sizeof(record));
cin >> a >> b >> d >> n;
if(a*b < 10)
{
record[a*b] = n;
}
else
{
int temp = a*b;
a = temp/10;
b = temp%10;
if(n == 1)
{
record[a] += 1;
record[b] += 1;
cout << record[d] << endl;
continue;
}
n++;
if(a+b < 10)
{
record[b] += 1;
record[a] += 1;
record[a+b] += n-2;
}
else
{
record[b] += 1;
record[(a+b)%10] += 1;
record[a+(a+b)/10] += 1;
record[(a+b+(a+b)/10)%10] += n-3;
}
}
cout << record[d] << endl;
}
return 0;
}
/*
5 4 2 5825956
*/