TJU-3860 Basex(模拟)
2015-07-17 14:41
323 查看
题目:
http://acm.tju.edu.cn/toj/showp3860.html
先是RE,再是WA。。。。。。
坑之处:
1、RE的原因,题目里只说了模是被空格隔开的,没说是几个空格,我当一个空格处理的
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/wail.gif)
。
2、WA的原因:人家没说给的数一定是n位。要自己在前面补0.
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/crazy.gif)
这么一道题调了半天,丢人啊
http://acm.tju.edu.cn/toj/showp3860.html
先是RE,再是WA。。。。。。
坑之处:
1、RE的原因,题目里只说了模是被空格隔开的,没说是几个空格,我当一个空格处理的
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/wail.gif)
。
2、WA的原因:人家没说给的数一定是n位。要自己在前面补0.
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/crazy.gif)
这么一道题调了半天,丢人啊
#include <cstdio> #include <cstdlib> #include <cstring> using namespace std; void work(int n) { int i, j, l; char str[50]; long long ans ; long long mod[50]; long long num[50]; for (i = 0; i < n; i++) { scanf("%s",str); if(str[0]>='0' && str[0]<='9') mod[i]=str[0]-'0'; else mod[i]=str[0] - 'A' + 10; } //for(i=0;i<n;i++) printf("%d\n",mod[i]); memset(str,0,sizeof(str)); scanf("%s",str); l=strlen(str); if(l<n) { for(i=n-1;i>=n-l;i--) str[i]=str[i-(n-l)]; for(i=0;i<n-l;i++) str[i]='0'; } for(i=0;i<strlen(str);i++) { if(str[i]>='0' && str[i]<='9') num[i]=str[i]-'0'; else num[i]=str[i]-'A'+10; } //for(i=0;i<n;i++) printf("%d\n",num[i]); ans = num[0]; for (i = 1; i < strlen(str); i++) ans =ans * mod[i] + (num[i]); printf("%lld\n", ans); } int main() { int n; while (~scanf("%d", &n)) work(n); return 0; }
相关文章推荐
- Oracle 使用小计(4)
- 认识MVC模型及其变种
- 全志a33核心板方案应用
- 12099 - The Bookcase
- Intent的定义及用法
- LeetCode - Majority Element II
- 深入浅出之-route命令实战使用指南
- (4.3.1.8)【项目一】子fragment之imageloader
- Python: Convert UTC time-tuple to UTC timestamp
- 约数之和
- WebSocket使用中碰到的问题以及解决方法
- linux 任务管理器
- Android 使用SpannableString显示复合文本
- Linux查看目录挂载点
- 查看网络图片
- Python的Django框架中设置日期和字段可选的方法
- GRE写作必备句型
- 安卓开发笔记——关于图片的三级缓存策略(内存LruCache+磁盘DiskLruCache+网络Volley)
- Swagger+Spring MVC框架学习分享
- Android搭建本地服务