hdu 5186(模拟)
zhx's submissions
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2293 Accepted Submission(s): 641
One day, zhx wants to count how many submissions he made on n ojs. He knows that on the ith oj, he made ai submissions. And what you should do is to add them up.
To make the problem more complex, zhx gives you n B−base numbers and you should also return a B−base number to him.
What's more, zhx is so naive that he doesn't carry a number while adding. That means, his answer to 5+6 in 10−base is 1. And he also asked you to calculate in his way.
For each test, there are two integers n and B separated by a space. (1≤n≤100, 2≤B≤36)
Then come n lines. In each line there is a B−base number(may contain leading zeros). The digits are from 0 to 9 then from a to z(lowercase). The length of a number will not execeed 200.
2
2
1 4
233
3 16
ab
bc
cd
233
14
#include <iostream>
#include <cstdio>
#include <string.h>
#include <queue>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long LL; int main(){
int n,m;
while(scanf("%d%d",&n,&m)!=EOF){
char res[];
char str[][];
int len[];
int MAX=-;
for(int i=;i<n;i++){
scanf("%s",str[i]);
len[i] = strlen(str[i]);
reverse(str[i],str[i]+len[i]);
MAX = max(MAX,len[i]);
}
for(int i=;i<n;i++){
for(int j=len[i];j<MAX;j++){
str[i][j] = '';
}
if(i==){
for(int j=;j<MAX;j++){
res[j] = str[][j];
}
}
}
int a,b;
for(int i=;i<n;i++){
for(int j=;j<MAX;j++){
if(str[i][j]<=''&&str[i][j]>='') a = str[i][j]-'';
else a = str[i][j]-'a'+;
if(res[j]<=''&&res[j]>='') b = res[j]-'';
else b = res[j]-'a'+;
int c = ((a+b-m)%m+m)%m;
if(c>=&&c<=) res[j] = c+'';
else res[j] = c-+'a';
}
}
reverse(res,res+MAX);
bool flag = false;
for(int i=;i<MAX-;i++){
if(res[i]!=''){
flag = true;
}
if(flag){
printf("%c",res[i]);
}
}
printf("%c\n",res[MAX-]);
}
return ;
}
hdu 5186(模拟)的更多相关文章
- HDU 5186 zhx's submissions 模拟,细节 难度:1
http://acm.hdu.edu.cn/showproblem.php?pid=5186 题意是分别对每一位做b进制加法,但是不要进位 模拟,注意:1 去掉前置0 2 当结果为0时输出0,而不是全 ...
- hdu 4891 模拟水题
http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...
- hdu 5012 模拟+bfs
http://acm.hdu.edu.cn/showproblem.php?pid=5012 模拟出骰子四种反转方式,bfs,最多不会走超过6步 #include <cstdio> #in ...
- hdu 4669 模拟
思路: 主要就是模拟这些操作,用链表果断超时.改用堆栈模拟就过了 #include<map> #include<set> #include<stack> #incl ...
- 2013杭州网络赛C题HDU 4640(模拟)
The Donkey of Gui Zhou Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- HDU - 5186 - zhx's submissions (精密塔尔苏斯)
zhx's submissions Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- HDU/5499/模拟
题目链接 模拟题,直接看代码. £:分数的计算方法,要用double; #include <set> #include <map> #include <cmath> ...
- hdu 5003 模拟水题
http://acm.hdu.edu.cn/showproblem.php?pid=5003 记得排序后输出 #include <cstdio> #include <cstring& ...
- hdu 5033 模拟+单调优化
http://acm.hdu.edu.cn/showproblem.php?pid=5033 平面上有n个建筑,每个建筑由(xi,hi)表示,m组询问在某一个点能看到天空的视角范围大小. 维护一个凸包 ...
随机推荐
- sping事务的理解
阅读数:2020 一.事务的基本原理 Spring事务的本质其实就是数据库对事务的支持,没有数据库的事务支持,spring是无法提供事务功能的.对于纯JDBC操作数据库,想要用到事务,可以按照以下步骤 ...
- 第一个Spring小程序实战
ps:本文偏向原理和操作性,原理适合于任何编译器. 支持Spring入门,目的是在xml文件里面装配相关bean(java对象),并实现获取.(IOC) 一.先建立一个Spring新项目,添加mave ...
- 201621123033 《Java程序设计》第13周学习总结
1. 本周学习总结 以你喜欢的方式(思维导图.OneNote或其他)归纳总结多网络相关内容. 2. 为你的系统增加网络功能(购物车.图书馆管理.斗地主等)-分组完成 为了让你的系统可以被多个用户通过网 ...
- Tomcat 中如何给 web 项目配置虚拟目录的方法
为什么要给 web 项目配置虚拟目录? 初学 JavaWeb 时,会发现只要我们把 web 项目放到 Tomcat 的 webapps 目录下,再通过 http://localhost:8080/项目 ...
- WCF身份验证三:自定义身份验证之<MessageHeader>
关于使用SoadHeader验证Robin已经有一篇十分精彩的文章: WCF进阶:为每个操作附加身份信息, 不过我的思维方式总是跟别人有点不太一样, 还是把类似的内容用我的方式重新组织一下. 使用He ...
- enter & keypress
enter & keypress https://stackoverflow.com/questions/905222/enter-key-press-event-in-javascript ...
- 微服务日志监控与查询logstash + kafka + elasticsearch
使用 logstash + kafka + elasticsearch 实现日志监控 https://blog.csdn.net/github_39939645/article/details/788 ...
- [洛谷P1536]村村通
题意:多组数据,当n为0时结束,每组数据表示有n个村子,m条路,求还需要建多少条路,使得所有的村子联通题解:用并查集求出有多少个联通块,然后求解 C++ Code: #include<cstdi ...
- hdu3068最长回文(Manacher算法)
简单来说这是个很水的东西.有点dp的思想吧.推荐两个博客,很详细. http://blog.csdn.net/xingyeyongheng/article/details/9310555 http:/ ...
- [HNOI2003]消防局的设立 (贪心)
[HNOI2003]消防局的设立 题目描述 2020年,人类在火星上建立了一个庞大的基地群,总共有n个基地.起初为了节约材料,人类只修建了n-1条道路来连接这些基地,并且每两个基地都能够通过道路到达, ...