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 ...
随机推荐
- ELK服务基础
官方文档 什么是ELK? 通俗来讲,ELK是由Elasticsearch.Logstash.Kibana三个开源软件组成的一个组合体,这三个软件当中,每个软件用于完成不同的功能,ELK又称为ELK s ...
- Python-装饰器-案例-获取文件列表
import os def get_all_path(fun): '''装饰器.功能:获取全路径文件名.如:D:/tmp/12.txt :param fun: :return:file_path_li ...
- Mirror--程序访问镜像数据库的超时机制
程序在访问有镜像的数据库和无镜像的数据库时,采用的链接超时时间算法不一样,因此会导致在在有镜像的数据库上设置了15 S的超时时间,而实际的超时时间仅为3.6 S,从而导致有镜像的数据库更容易超时. 在 ...
- JS事件常用事件
oncontextmenu对象右击 举例1: <form id="form1" name="form1" method="post" ...
- Openstack(十)部署nova服务(计算节点)
在计算节点安装 10.1安装nova计算服务 # 阿里云源详见2.3配置 # yum install openstack-nova-compute 10.2配置nova计算服务 10.2.1配置nov ...
- HTML5中的本地、WebSql、离线应用存储
1. HTML5存储相关API a) Localstorage 本地存储 b) Web Sql DataBase 本地数据库存储 c) .manifest 离线应用存储 2. HT ...
- mysql++使用
Mysql++是官方发布的.一个为MySQL设计的C++语言的API.Mysql++为Mysql的C-Api的再次封装,它用STL(Standard Template Language)开发并编写,并 ...
- docker——三剑客之Docker Compose
编排(Orchestration)功能是复杂系统实现灵活可操作性的关键.特别是在Docker应用场景中,编排意味着用户可以灵活的对各种容器资源实现定义和管理. 作为Docker官方编排工具,Compo ...
- BUG克星:几款优秀的BUG跟踪管理软件
Bug管理是指对开发,测试,设计等过程中一系列活动过程中出现的bug问题给予纪录.审查.跟踪.分配.修改.验证.关闭.整理.分析.汇总以及删除等一系列活动状态的管理.,最后出相应图表统计,email通 ...
- gstreamer调试命令
gplay播放命令 gplay 文件全路径 (eg:gplay 123.mp3) gstreamer播放命令 gst-launch playbin2 uri=file:///文件全路径 (eg gs ...