题解 | #特殊乘法#
特殊乘法
https://www.nowcoder.com/practice/a5edebf0622045468436c74c3a34240f
#include <iostream>
#include <string>
using namespace std;
int main() {
string a, b;
while (cin >> a >> b) { // 注意 while 处理多个 case
long long res = 0;
for (int i = 0; i < a.size(); i++) {
int a1 = a[i] - '0';
for (int j = 0; j < b.size(); j++) {
int b1 = b[j] - '0';
int k = a1 * b1;
res = res + k;
}
}
printf("%lld\n", res);
}
}
// 64 位输出请用 printf("%lld")

查看7道真题和解析