- 取石子
B进制星球怎么写??
- 2025-7-21 19:08:17 @
col | |
---|---|
content | |
1 条评论
-
jinhongyi @ 2025-7-22 10:54:44
#include<bits/stdc++.h> using namespace std; int a[10005],b[10005],c[100005]; int main(){ string s,t; int r; cin>>r>>s>>t; reverse(s.begin(),s.end()); reverse(t.begin(),t.end()); for(int i=0;i<s.size();i++){ if(s[i]>='1' and s[i]<='9'){ a[i]=s[i]-'0'; } else if(s[i]>='A' and s[i]<='Z'){ a[i]=s[i]-55; } } for(int i=0;i<t.size();i++){ if(t[i]>='1' and t[i]<='9'){ b[i]=t[i]-'0'; } else if(t[i]>='A' and t[i]<='Z'){ b[i]=t[i]-55; } } int clen=max(s.size(),t.size()); for(int i=0;i<clen;i++){ c[i]+=a[i]+b[i]; c[i+1]=c[i]/r; c[i]%=r; } if(c[clen]){ clen++; } for(int i=clen-1;i>=0;i--){ if(c[i]>9){ cout<<char(c[i]+55); } else cout<<c[i]; } }
- 1
信息
- ID
- 116
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- 递交数
- 56
- 已通过
- 9
- 上传者