复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93#include<cstdio> #include<algorithm> #include<cmath> #include<cstring> using namespace std; int main() { char str1[20]; char str2[20]; while(scanf("%s %s",str1,str2)!=EOF) { int cont1=1,cont2=1; if(str1[0]=='-') cont1=0; if(str2[0]=='-') cont2=0; long long ans1,ans2; ans1=0; ans2=0; int len1=strlen(str1)-1; int len2=strlen(str2)-1; int zhishu=0; long long cnum=1; while(1) { if(len1<0||str1[len1]=='+'||str1[len1]=='-') break; if(str1[len1]>='A'&&str1[len1]<='F') zhishu=str1[len1]-'A'+10; else zhishu=str1[len1]-'0'; cnum*=16; ans1+=zhishu*cnum; len1--; } cnum=1; while(1) { if(len2<0||str2[len2]=='+'||str2[len2]=='-') break; if(str2[len2]>='A'&&str2[len2]<='F') zhishu=str2[len2]-'A'+10; else zhishu=str2[len2]-'0'; cnum*=16; ans2+=zhishu*cnum; len2--; } if(cont1==0) ans1=-ans1; if(cont2==0) ans2=-ans2; char astr[100]; long long ans3=ans1+ans2; int cont4=0; if(ans3<0) { cont4=1; ans3=-ans3; } int cont=0; //printf("%lld %lldn",ans1,ans2); if(ans3==0) { printf("0n"); continue; } while(ans3!=0) { long long t1; t1=ans3%16; if(t1>=10) { astr[cont]=t1-10+'A'; } else astr[cont]=t1+'0'; ans3/=16; cont++; } if(cont4==1) { astr[cont]='-'; cont++; } for(int i=cont-1;i>=1;i--) printf("%c",astr[i]); printf("n"); } return 0; }
最后
以上就是真实短靴最近收集整理的关于hdu 2057的全部内容,更多相关hdu内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复