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 ...
随机推荐
- NSURLSession 和 NSURLConnection 的比较
一.NSURLConnection 1.iOS2.0出现,iOS9.0后废弃的网络请求发送方式 2.可以在初始化时确定发送同步还是异步的请求,并且可以选择执行队列. +(void)sendAsynch ...
- 大数据攻城狮之Hadoop伪分布式篇
对于初学大数据的萌新来说,初次接触Hadoop伪分布式搭建的同学可能是一脸萌笔的,那么这一次小编就手把手的教大家在centos7下搭建Hadoop伪分布式. 底层环境: VMware Workstat ...
- Django基础必备三件套: HttpResponse render redirect
1. HttpResponse : 它的作用是内部传入一个字符串参数, 然后发给浏览器 def index(request): return HttpResponse('ok') 2. render ...
- 日期数据类型为Date ,前台传递喂String的后台处理
方法一: 在实体类里面将set方法里面将数据类型转为Date public void setBirth(String birth) { SimpleDateFormat sdf = new Simpl ...
- java的random生成某个范围内的随机数
import java.util.Random; /** * @author HP * @date 2019/4/16 */ public class randomTest { public stat ...
- poj1958-汉诺四塔问题(三种方法)
链接:http://poj.org/problem?id=1958 大意:汉诺塔升级版,四根柱子,n个盘子,求最少移动次数: 两种方法 递推or递归(当然还有思路3--打表) 思路1:递推(或者DP? ...
- Python-操作符和表达式
//: 除后向下取正 -3//2=-2 **: 幂 3**3 = 27 not: ! and: && or: || 除了以上几个之外,其余与C++相同 length = 3 widt ...
- windows phone控件
常用控件: 包括: Button控件.CheckBox控件.HyperlinkButton控件.Iamege控件.ListBox控件.PasswordBox控件.ProgressBar控件.Radio ...
- 2018年排名前20的数据科学Python库
Python 在解决数据科学任务和挑战方面继续处于领先地位.业已证明最有帮助的Python库,我们选择 20 多个库,因为其中一些库是相互替代的,可以解决相同的问题.因此,我们将它们放在同一个分组. ...
- JavaScript中比较运算符的使用
比较运算符的基本操作过程是:首先对操作数进行比较,这个操作数可以是数字也可以是字符串,然后返回一个布尔值true或false. 在JavaScript中常用的比较运算符如下表所示. 例如,某商场店庆搞 ...