很早前做的高精度,贴上来
#include<iostream> #include<cstring> using namespace std; int main() { int t; cin >> t; while(t--) { string s; int b; cin >> s >> b; if(b==0) { cout << 0 << endl; continue; } int a[10000] = {0}; int h = s.length(); for(int i = 0; i < h; i ++) a[i] = s[h-i-1] - '0'; for(int i = 0; i < h; i++) a[i] *= b; for(int i = 0; i < h; i++) if(a[i]>=10) { a[i+1] += a[i]/10; a[i] %= 10; } if(a[h] != 0) cout << a[h]; for(int i = 0; i < h; i++) cout << a[h-i-1]; cout << endl; } }