HDU 5186
easy !!
#include <iostream>
#include <cstdio>
#include <algorithm>
#define LL __int64
using namespace std; int input[],l;
char in[];
struct BigNumber{
int B,len;
int num[];
void init(){
len=;
for(int i=;i<=;i++) num[i]=;
}
void add_BigNubmer(int *a,int l){
len=max(len,l);
// cout<<len<<endl;
int mod,up;
for(int i=;i<len;i++){
mod=(a[i]+num[i])%B;
num[i]=mod;
}
if(num[len]) len++;
}
}; void Init(){
for(int i=;i<=;i++) input[i]=;
} int main(){
BigNumber Number;
int n,B;
while(scanf("%d%d",&n,&B)!=EOF){
Number.init();
Number.B=B;
for(int i=;i<n;i++){
scanf("%s",in);
int len=strlen(in);
l=;
Init();
for(int i=len-;i>=;i--){
if(in[i]>=''&&in[i]<='')
input[l]=in[i]-'';
else if(in[i]>='a'&&in[i]<='z')
input[l]=in[i]-'a'+;
l++;
}
Number.add_BigNubmer(input,l);
}
bool flag=false;
for(int i=Number.len-;i>=;i--){
if(!flag&&Number.num[i]==){
continue;
}
flag=true;
if(Number.num[i]<=)
printf("%c",Number.num[i]+'');
else if(Number.num[i]>)
printf("%c",Number.num[i]-+'a');
}
if(!flag) printf("");
puts("");
}
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 - 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 ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
随机推荐
- B1003 物流运输(最短路 + dp)
这个dp其实不是那么难,状态其实很好想,但是细节有少许偏差. 当时我并没有想到最短路要在dp之外写,后来看题解之后发现要预处理出来每段时间1~M的最短路,然后直接dp. 题目: Description ...
- bzoj 4709 [ Jsoi2011 ] 柠檬 —— 斜率优化DP
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4709 课上讲的题,还是参考了博客...:https://www.cnblogs.com/GX ...
- JS——事件详情(鼠标事件:clientX、clientY的用法)
鼠标位置 >可视区位置:clientX.clientY 跟着鼠标移动的div案例 代码如下图: 这个案例,运用到前一篇文章中的event事件来处理.获取div的left和top值,当鼠标移动 ...
- C# 创建单例
private static WorkFlow instance = null; private static readonly object syncObj = new ob ...
- dom转换成jquery对象
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- 前端-Vue结构思维导图笔记
看不清的朋友右键保存或者新窗口打开哦!喜欢我可以关注我,还有更多前端思维导图笔记有vue结构分析,JS基础,JQ,JS高级,Angular,git等等
- shiro登陆权限验证
一>引入shirojar包 <!-- shiro登陆权限控制 --> <dependency> <groupId>org. ...
- 省市区县的sql语句——城市
/*SQLyog v10.2 MySQL - 5.5.48 : Database - 省市县****************************************************** ...
- JWPL工具处理维基百科wikipedia数据用于NLP
JWPL处理维基百科数据用于NLP 处理zhwiki JWPL是一个Wikipedia处理工具,主要功能是将Wikipedia dump的文件经过处理.优化导入mysql数据库,用于NLP过程.以下以 ...
- java Web(4)
Web 应用程序状态管理 通过隐藏表单域 hidden,cookie,session,重写URL来实现: cookie存在于客户端,浏览器关闭时失效 cookie原理:服务器在响应请求时将一些数据以“ ...