HDU 5186 zhx's submissions 模拟水题
来源:互联网 发布:网络主播团队 编辑:程序博客网 时间:2024/05/09 10:55
题意就是给n个b进制的数,求它们相加的和,有一个条件就是相加不进位,输出结果为没有前导0.
(原来有中文题的。只能说英文太渣没有看到输出结果没有前导0这个条件。)
代码:
//author: CHC//First Edit Time: 2015-03-14 19:09#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <set>#include <vector>#include <map>#include <queue>#include <set>#include <algorithm>#include <limits>using namespace std;typedef long long LL;const int MAXN=1e+4;const int MAXM=1e+5;const int INF = numeric_limits<int>::max();const LL LL_INF= numeric_limits<LL>::max();int getnums(char ch){ if(ch>='0'&&ch<='9')return ch-'0'; else return 10+ch-'a';}char getchar(int num){ if(num>=0&&num<=9)return num+'0'; else return num-10+'a';}char strs[200][300];char tmp[300];char ans[300];int main(){ int n,k; while(~scanf("%d%d",&n,&k)){ memset(strs,0,sizeof(strs)); for(int i=0;i<n;i++){ scanf("%s",tmp); for(int j=strlen(tmp)-1,k=0;j>=0;j--,k++){ strs[i][k]=tmp[j]; } } memset(ans,'0',sizeof(ans)); int m_len=0; for(int i=0;i<n;i++){ int len=strlen(strs[i]); m_len=max(len,m_len); for(int j=0;j<len;j++){ ans[j]=getchar((getnums(ans[j])+getnums(strs[i][j]))%k); } } int flag=m_len; for(;flag>0&&ans[flag]=='0';flag--); for(int i=flag;i>=0;i--)putchar(ans[i]); puts(""); } return 0;}
0 0
- HDU 5186 zhx's submissions 模拟水题
- hdu 5186 zhx's submissions(模拟)
- hdu 5186 zhx's submissions
- HDU - 5186 zhx's submissions
- hdu 5186 zhx's submissions
- HDU-5186-zhx's submissions(Java+简单模拟)
- HDU 5186 zhx's submissions (进制转换)
- HDU - 5186 - zhx's submissions (大数高精度)
- 杭电 HDU ACM 5186 zhx's submissions
- hdu 5186 zhx's submissions 5187 zhx's contest快速幂小优化
- hdu5186 zhx's submissions
- 【CUGBACM15级BC第33场 A】hdu 5186 zhx's submissions
- BestCoder #33 zhx's submissions
- BestCoder Round #33 1001 zhx's submissions
- zhx's contest HDU
- HDU 5187 zhx's contest
- HDU - 5187 zhx's contest
- hdu 5187-zhx's contest
- Sicily 1304. Delivering Food
- 第二周项目二:长方柱类
- POJ 题目3020 Antenna Placement(二分图)
- 第二周项目一旱冰场造价
- Sicily 1903. Farey Sequence Again
- HDU 5186 zhx's submissions 模拟水题
- uva 562 (dp找平均差异最小值)
- Git 学习笔记
- Sicily 1933. Wine trading in Gergovia
- windows屏幕保护opengl程序模板
- 预处理器标识
- 我们所要做的,就是找到那个爱真正你的人。
- 第二周项目三:时间类
- 分布式发布订阅消息系统 Kafka 架构设计