AcWing 3390. 特殊乘法
题目
给定一个 位整数 ,各位从高到低依次为 。
给定一个 位整数 ,各位从高到低依次位 。
给定一种特殊乘法,不妨用 来表示,我们规定
例如,。
对于给定的 和 ,请你计算并输出 的值。
输入格式
两个整数 和 。
输出格式
一个整数,表示 的值。
数据范围
输入样例:
123 45
输出样例:
54
题解 - yxc版本
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
string a, b;
cin >> a >> b;
int res = 0;
for (auto x: a)
for (auto y: b)
res += (x - '0') * (y - '0');
cout << res << endl;
return 0;
}