杭电 hdu 1720
A+B Coming:
本题使用模拟法但是没有AC。
//AC
#include<stdio.h>
int main(){int m,n;while(scanf("%x%x",&m,&n)!=EOF)printf("%d\n",m+n);return 0;
}
//WA
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;
#define N 1000
char str1[N],str2[N];
int main(){while(cin>>str1>>str2){int len1=strlen(str1);int sum1=0;int i;for(i=0;i<len1;++i){if(str1[i]<='9'&&str1[i]>='0')sum1+=(str1[i]-'0')*pow(10.0,len1-1-i);else{if(str1[i]<='F'&&str1[i]>='A')sum1+=(str1[i]-'A'+10)*pow(10.0,len1-1-i);elseif(str1[i]<='f'&&str1[i]>='a')sum1+=(str1[i]-32-'A'+10)*pow(10.0,len1-1-i);}}int len2=strlen(str2);int sum2=0;for(i=0;i<len2;++i){if(str2[i]<='9'&&str2[i]>='0')sum2+=(str2[i]-'0')*pow(10.0,len2-1-i);else{if(str2[i]<='F'&&str2[i]>='A')sum2+=(str2[i]-'A'+10)*pow(10.0,len2-1-i);elseif(str2[i]<='f'&&str2[i]>='a')sum2+=(str2[i]-32-'A'+10)*pow(10.0,len2-1-i);}}cout<<sum1+sum2<<endl;memset(str1,'0',N*sizeof(char));memset(str2,'0',N*sizeof(char));}return 0;
}
转载于:https://blog.51cto.com/beyond316/1259928
杭电 hdu 1720相关推荐
- 杭电 HDU ACM 圆桌会议
圆桌会议 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- 杭电 hdu 1175 连连看 测试数据
/* THE PROGRAM IS MADE BY PYY */ /*----------------------------------------------------------------- ...
- 杭电 hdu 1874 畅通工程续
第二次 /* THE PROGRAM IS MADE BY PYY */ /*------------------------------------------------------------- ...
- 杭电 hdu 2096
小明A+B: #include<iostream> using namespace std; int main(){int n;cin>>n;cin.ignore();whil ...
- 杭电 hdu 1003
Max Sum: 本题同样没有AC,解题思路很简单. #include<iostream> #include<string.h> using namespace std; #d ...
- 杭电 hdu 2040
亲和数: #include<iostream> using namespace std; long long Test(long long n){long long i,sum=0;for ...
- 杭电 hdu 2019
数列有序!: #include<iostream> using namespace std; #define N 1000 int a[N]; int main(){int n,m;whi ...
- 杭电 hdu 3343
An ant's story: #include<iostream> using namespace std; int main(){int n;cin>>n;cin.igno ...
- 杭电HDU 1004 Let the Balloon Rise AC代码 简单题
题目很简单,大致意思是有多组测试数据,每组测试数据里找出出现次数最多的字符串,输入0结束.这个题没什么坑点,而且题目说了是唯一解. 用了结构体,algorithm里的sort函数就解决了,贴 C++的 ...
最新文章
- 从Ruby调用Shell命令
- sharepoint column中的图片链接不能显示为图片
- jQuery banner切换插件
- 华为数据库2019年度大盘点
- python制作桌面小程序_微信小程序在线制作:快速生成一个餐饮小程序
- MFC UI库知多少
- Android系统性能调优工具介绍
- 学了python可以干嘛-学 Python 都用来干嘛的?
- mini2440 uboot使用nfs方式引导内核,文件系统
- 如何在Linux系统列出systemd下所有正在运行的服务
- python中的列表推导与生成器
- jquery 发送验证码60s倒计时,后重新发送
- vue弹出alert_vue.extend实现alert模态框弹窗步骤详解
- java如何让源码加密还能运行_如何有效防止Java程序源码被人偷窥?
- Python使用超级鹰识别验证码
- 禁用ubuntu16.04的guest账户
- 从多个Word文档中批量取值,整理到Excel表中。
- react 命名规范 书写顺序
- 工业设计公司如何进行家电设计创新?
- 格式工厂找不到qlv文件无法添加qlv文件 怎么办 解决方法