HDU 5186 zhx's submissions 模拟,细节 难度:1
http://acm.hdu.edu.cn/showproblem.php?pid=5186
题意是分别对每一位做b进制加法,但是不要进位
模拟,注意:1 去掉前置0 2 当结果为0时输出0,而不是全部去掉
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=101;
const int maxm=201;
int n,b;
char a[maxn][maxm];
int len[maxn];
char ans[maxm];
int getnum(char c){
if(c>='0'&&c<='9')return c-'0';
return c-'a'+10;
}
char getchar(int t){
if(t<10)return '0'+t;
return 'a'+t-10;
}
void add(int ind,int num){
int tmp=(getnum(ans[ind])+num)%b;
ans[ind]=getchar(tmp);
}
int main(){
while(scanf("%d%d",&n,&b)==2){
int mxlen=0;
for(int i=0;i<n;i++){
scanf("%s",a[i]);
len[i]=strlen(a[i]);
mxlen=max(mxlen,len[i]);
}
for(int i=0;i<mxlen;i++)ans[i]='0';
ans[mxlen]=0;
for(int j=1;j<=mxlen;j++){
for(int i=0;i<n;i++){
if(len[i]>=j){
add(mxlen-j,getnum(a[i][len[i]-j]));
}
}
}
int ind;
for(ind =0;ans[ind]=='0'&&ind<mxlen-1;ind++){}
printf("%s\n",ans+ind); }
return 0;
}
HDU 5186 zhx's submissions 模拟,细节 难度:1的更多相关文章
- HDU - 5186 - zhx's submissions (精密塔尔苏斯)
zhx's submissions Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- HDU 5186 zhx's submissions (进制转换)
Problem Description As one of the most powerful brushes, zhx submits a lot of code on many oj and mo ...
- hdu 5186(模拟)
zhx's submissions Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)
HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...
- HDU 4782 Beautiful Soup (模拟+注意细节)
思路就是用栈模拟,不用开实体的栈,直接记一个top指针就行. 说说这题的细节: 1.tag标签里的内容不要动,原样输出.比如<p aa bb cc>,就这样输出就行,不要删空格.题目中说了 ...
- HDU 5867 Water problem (模拟)
Water problem 题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5867 Description If the numbers ...
- HDU 5948 Thickest Burger 【模拟】 (2016ACM/ICPC亚洲区沈阳站)
Thickest Burger Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- HDU 5920 Ugly Problem 【模拟】 (2016中国大学生程序设计竞赛(长春))
Ugly Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- HDU 5873 Football Games 【模拟】 (2016 ACM/ICPC Asia Regional Dalian Online)
Football Games Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
随机推荐
- python基础之函数式编程、匿名函数、内置函数
一 函数式编程 不修改外部状态. 模仿数学里得函数进行编程. 用函数编程写出得代码相当精简. 可读性比较差. 例子: y=2*x+1 x=1 def test(x): return 2*x+1 tes ...
- Openstack(六)RabbitMQ集群
各组件通过消息发送与接收是实现组件之间的通信: 6.1安装RabbitMQ 6.1.1安装RabbitMQ # yum install rabbitmq-server –y # systemctl s ...
- [LeetCode] 82. Remove Duplicates from Sorted List II_Medium tag: Linked List
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinctnumbe ...
- enum 枚举类型默认值
enum value { one, two, three, four }; 默认值
- 454 Authenti cation failed, please open smtp flag first! (Net::SMTPAuthenticationError)
在用ruby的smtp库发送邮件的时候,出现了这个错误454 Authenti cation failed, please open smtp flag first! (Net::SMTPAuthen ...
- acdream1174 合并同类项
这题说的是 给出N,a[1]... a[N],还有M,b[1]... b[M]long long ans = 0;for(int i = 1; i <= N; i ++) for(int ...
- flask后端 获取不到form表单post 的文件
原文地址http://docs.jinkan.org/docs/flask/patterns/fileuploads.html <form> 标签被标记有 enctype=multipar ...
- FMS4
先要打开服务器你在本机装的fms,本机就是服务器了!记得现在你的机器既是客户端又是服务端开始===程序===Macromedia===Flash Media Server 2有两个start****, ...
- 【读书笔记】Junit实战
Junit实战读书笔记 第一章节 探索Junit: Junit是1997年Erich Gammay和Kent Beck一同创建的一个简单有效的测试框架,其中Erich Gammay是经典<设计模 ...
- INNODB索引与算法
在之前的博文中简单提到了索引的分类与索引的可选择性查看:Click HERE 这片博客主要包含内容:索引组织表,索引算法B+树简单介绍 索引组织表 在innodb存储引擎中,表都是根据主键顺序组织存放 ...