【HDU】3787 A+B-->有逗号版(其实是手读)
来源:互联网 发布:betterzip mac 编辑:程序博客网 时间:2024/06/14 12:57
算是收获了奇怪的手读么emmm
传送门
Time Limit: 1000 MS
Memory Limit: 32768 K
Problem Description
给定两个整数A和B,其表示形式是:从个位开始,每三位数用逗号”,”隔开。
现在请计算A+B的结果,并以正常形式输出。
Input
输入包含多组数据数据,每组数据占一行,由两个整数A和B组成(-10^9 < A,B < 10^9)。
Output
请计算A+B的结果,并以正常形式输出,每组数据占一行。
Sample Input
-234,567,890 123,456,789
1,234 2,345,678
Sample Output
-111111101
2346912
题目本身简单易懂,主要在于这种有逗号的怎么去处理,把两个数当成string来处理,用一下精良版?手读来读进来过滤逗号
代码如下:
#include<iostream>#include<cstdio>#include<cstdlib>#include<cmath>using namespace std; string a,b;int read(string a) { int x=0; if(a[0]=='-') { for(int i=1;i<a.length();i++) if(a[i]>='0'&&a[i]<='9') x = x*10+a[i]-'0'; x=-x; } else { for(int i=0;i<a.length();i++) if(a[i]>='0'&&a[i]<='9') x = x*10+a[i]-'0'; } return x;} int main() { while(cin>>a>>b) cout<<read(a)+read(b)<<endl; return 0;}
阅读全文
2 0
- 【HDU】3787 A+B-->有逗号版(其实是手读)
- hdu 3787 A+B
- hdu-3787-A+B
- HDU 3787 A+B
- hdu 3787 A+B
- HDU 3787 A+B
- HDU 3787 A+B
- A+B (数中含有逗号)
- [HDU 1402]A * B Problem Plus(其实是FFT模板)
- hdu 3787 A+B(水)
- 逗号表达式 c = a,b; d = (a,b);
- HDU 又一版 A+B
- HDU 1866 A + B forever! 有坑,注意题意!!!
- YT14-HDU-满足(a^2+b^2 +m)/(ab)的(a,b)有多少
- 逗号表达式 result = (a+4,b+3,a+b) ...result = a+b;
- HDU(3787)——A+B
- hdu 3787 A+B(简单字符串处理)
- HDU 1877 又一版 A+B
- 利用apache ab命令完成性能测试
- python编程中的if __name__ == 'main': 的作用和原理
- ubuntu配置vim
- C++:函数指针
- python基础系列教程——Python库的安装与卸载
- 【HDU】3787 A+B-->有逗号版(其实是手读)
- GridView网格视图
- Android讲义3---第五章---Data,Type属性与intent-filter配置
- tensorflow之简单卷积神经网络(CNN)搭建
- angularjs工作原理解析
- HTML标签
- 77.组合问题
- 搭建图片服务器
- centos5.5 无法使用yum解决办法