| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 166996 | 谢嘉昱 | N进制数加法 | C++ | Wrong Answer | 16 | 1 MS | 252 KB | 639 | 2024-08-19 15:46:36 |
#include <bits/stdc++.h> using namespace std; int main() { string w="0123456789ABCDEFGHIJKLNMOPQRSTUVWXYZ"; string a,b; int N,x[100],y[100]; cin>>N>>a>>b; while(a.length()<b.length()) { a='0'+a; } while(a.length()>b.length()) { b='0'+b; } a='0'+a; b='0'+b; for(int i =a.length()-1;i>=0;i--) { x[i]=w.find(a[i],0); y[i]=w.find(b[i],0); } for(int i =a.length()-1;i>=0;i--) { x[i]+=y[i]; if(x[i]>N) { for(int k=i;x[k]>N;k--) { x[k]-=N; x[k-1]++; } a[i]=w[x[i]]; } } while(a[0]=='0') { a.erase(0,1); } cout << (a.length()==0?"0":a) << endl; }