[水]ZOJ1205
来源:互联网 发布:网络flash英文歌曲 编辑:程序博客网 时间:2024/05/16 01:05
20进制的高精加法
没有坑1A
#include <bits/stdc++.h>using namespace std;char a[200],b[200];int Get(char ch){ if (ch>='0'&&ch<='9') return ch-'0'; else return ch-'a'+10;}char rGet(int ch){ if (ch>=0&&ch<=9) return ch+'0'; else return ch-10+'a';}void Gao(){ int a1[200],a2[100],len1,len2,l; memset(a1,0,sizeof(a1)); memset(a2,0,sizeof(a2)); len1=strlen(a);len2=strlen(b); l=max(len1,len2); for (int i=len1-1;i>=0;i--) a1[len1-i]=Get(a[i]); for (int i=len2-1;i>=0;i--) a2[len2-i]=Get(b[i]); for (int i=1;i<=l;i++) { a1[i]+=a2[i]; a1[i+1]+=a1[i]/20; a1[i]%=20; } if (a1[l+1]>0) l++; for (int i=l;i>=1;i--) printf("%c",rGet(a1[i])); cout<<endl;}int main(){ //freopen("a.in","r",stdin); while(scanf("%s%s",a,b)!=EOF) Gao(); return 0;}
0 0
- [水]ZOJ1205
- zoj1205
- zoj1205
- Zoj1205
- zoj1205
- zoj1205
- Python--ZOJ1205
- zoj1205-----------Martian Addition 大数处理
- 2012-12-08 11:25 ZOJ1205
- 水
- 水
- 水
- 水
- 水
- 水
- 水
- 水
- 水
- android4.4 Keyguard 锁屏之----布局篇
- 使用 Broadcast Receiver 接收广播消息
- 关于ListView中adapter调用notifyDataSetChanged无效的原因
- Hibernate学习_001_模拟hibernate的实现
- 那么相似,可还不是-------Day84
- [水]ZOJ1205
- Linux中硬链接和软链接的区别和联系
- bzoj1669 [Usaco2006 Oct]Hungry Cows饥饿的奶牛
- Fermat’s Chirstmas Theorem(素数筛)
- 自己写的atoi函数
- 剪贴板应用
- 未能找到类型或命名空间名称"xxxxxx"的真正原因
- 二分图的判定
- HDU 1004 Let the Balloon Rise