System Message (命题人) yule_z (测试)
基准时间限制:1 秒 空间限制:262144 KB 分值: 20ios
统计一下,(n个a) × b 的结果里面有多少个数字d,a,b,d均为一位数。
样例解释:
3333333333*3=9999999999,里面有10个9。测试
Input
多组测试数据。
第一行有一个整数T,表示测试数据的数目。(1≤T≤5000)
接下来有T行,每一行表示一组测试数据,有4个整数a,b,d,n。 (1≤a,b≤9,0≤d≤9,1≤n≤10^9)
Output
对于每一组数据,输出一个整数占一行,表示答案。
Input示例
2
3 3 9 10
3 3 0 10
Output示例
10
0spa
Visual C++的运行时限为:1000 ms ,空间限制为:262144 KBcode
win10
visual studio 2015ci
#include<iostream> using namespace std; int main() { int T; cin >> T; for (int i = 0;i < T;i++) { int a, b, d; long n; cin >> a >> b >> d >> n; long c=0; int ab = a*b; if (ab < 10) { if (ab == d){ c+=n; } } else {//ab>9 int ab0 = ab % 10; int ab1 = ab / 10; int and=ab0+ab1; if (and < 10){ if(d==and){ c+=n-1; } if(d==ab0){ c+=1; } if(d==ab1){ c+=1; } } else{//and >9 if(d==ab0){ c+=1; } if(d==(and-10)){ c+=1; } if(d==(and-9)){ c+=n-2; } if(ab1==9){ if(d==0){ c+=1; } if(d==1){ c+=1; } } else{ if(d=ab1+1){ c+=1; } }//endelse a!=9 }//endelse and>9 }//endelse ab>9 cout<<c<<endl; } return 0; }
结果是Wrong Anwser。
请问错误在于哪里?io