标签:输出 max string ble level cti int define har
第1行:大数A 第2行:大数B (A,B的长度 <= 1000,A,B >= 0)
输出A * B
123456
234567
28958703552
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define MAX 50000 #define DMAX 10000 using namespace std; typedef long long ll; char a[1005],b[1005]; char ans[2005]; int main() { scanf("%s%s",a,b); int d = 0,alen = strlen(a),blen = strlen(b); for(int i = 0;a[i];i ++) { for(int j = 0;b[j];j ++) { d += (a[alen - 1 - i] - ‘0‘) * (b[blen - 1 - j] - ‘0‘); if(ans[i + j]) d += ans[i + j] - ‘0‘; ans[i + j] = d % 10 + ‘0‘; d /= 10; } if(d) { ans[i + blen] = d + ‘0‘; d = 0; } } reverse(ans,ans + strlen(ans)); printf("%s",ans); }
标签:输出 max string ble level cti int define har
原文地址:https://www.cnblogs.com/8023spz/p/10055827.html