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组询问在某一个点能看到天空的视角范围大小. 维护一个凸包 ...
随机推荐
- VirtualBox上安装ubuntu
当安装完成,重启后,在启动界面出现Please remove the installation medium,then press ENTER.问题? 解决方法:在VirtualBox里面通过iso文 ...
- weak_ptr打破环状引用
转自:http://blog.csdn.net/malong777/article/details/48974559 weak_ptr是一种不控制对象生存周期的智能指针,它指向一个shared_ptr ...
- 我和C语言程序
姓名:江超鸿 学号:160809129 爱好:打台球.听音乐 博客地址:https://www.cnblogs.com/jiangchaohong/ C语言:对于c语言程序来说,我是第一次接触,对它的 ...
- 关于MySQL的异常处理 Can't connect to MySQL server on localhost (10061)解决方法
首先检查MySQL 服务没有启动>如果没有启动,则要启动这个服务. 昨天,重起服务器后出现MySQL 'localhost' (10061)错误,开始以为是因为数据库链接打开过多,数据库资源耗尽 ...
- linux cfs 负载均衡
确定新的负载的时候,代码中给出的公式是: (old×(2^i-1) + new))/2^i 整理下来是: old + (new-old)/2^i i的范围是[1, 4],也就是说,i的层级越高,那么n ...
- 论 Web 前端加密的意义
论 Web 前端加密的意义 Web前端密码加密是否有意义? https://www.zhihu.com/question/25539382 https://blog.csdn.net/hla19910 ...
- [NOI2002] 银河英雄传说 (带权并查集)
题目描述 公元五八○一年,地球居民迁至金牛座α第二行星,在那里发表银河联邦创立宣言,同年改元为宇宙历元年,并开始向银河系深处拓展. 宇宙历七九九年,银河系的两大军事集团在巴米利恩星域爆发战争.泰山压顶 ...
- Codeforces ----- Kefa and Dishes [状压dp]
题目传送门:580D 题目大意:给你n道菜以及每道菜一个权值,k个条件,即第y道菜在第x道后马上吃有z的附加值,求从中取m道菜的最大权值 看到这道题,我们会想到去枚举,但是很显然这是会超时的,再一看数 ...
- 一个简易的Python全站抓取系统
很长时间没有更新博客了,前一阵时间在做项目,里面有一个爬虫系统,然后就从里面整理了一点代码做成了一个简易的爬虫系统,还挺实用的. 简单说来,这个爬虫系统的功能就是:给定初始的链接池,然后设定一些参数, ...
- spring @Profile的运用示例
@Profile的作用是把一些meta-data进行分类,分成Active和InActive这两种状态,然后你可以选择在active 和在Inactive这两种状态 下配置bean, 在Inactiv ...