BestCoder #33 zhx's submissions
来源:互联网 发布:java求素数 编辑:程序博客网 时间:2024/05/20 02:53
解题报告不写了,光贴个代码。。主要是注意各个符号,然后字符串的变换等等。
#include <iostream>#include <stdio.h>#include <string.h>#include <vector>#include <map>#include <algorithm>#include <queue>#include <cmath>#include <bitset>using namespace std;// 大数,内存处理const int INF = 0x3f3f3f3f;#define ll long long int#define MEM(a) memset(a, 0, sizeof(a))#define MEMM(a) memset(b, -1, sizeof(b))#define DEB(x, n) cout << (x) << " " << (n) << endl;#define putCR printf("\n")const int maxn = 210;char num[maxn];char a[maxn], b[maxn];int n, B;inline int getnum(char &a){ if(a >= '0' && a <= '9') return a-'0'; else return a-'a'+10;}inline char cal(char &a, char &b){ int t1 = getnum(a); int t2 = getnum(b); t1 = (t1 + t2) % B; if(t1 < 10) return t1+'0'; else return t1-10+'a';}// 字符串翻转inline void trans(char *a){ int len = strlen(a); // printf("%d", len); for(int i = 0; i < len/2; i++) swap(a[i], a[len-i-1]);}inline void add(char *a, char *b){ int len1 = strlen(a); int len2 = strlen(b); int len, rest; if(len1 > len2) { len = len2; rest = len1; } else { len = len1; rest = len2; } for(int i = 0; i < len; i++) a[i] = cal(a[i], b[i]); if(rest == len1) return; else for(int i = len; i < len2; i++) a[i] = b[i];}int main(){#ifdef DEBUG freopen("input", "r", stdin);#endif int len; while(scanf("%d%d", &n, &B)!= EOF) { memset(num, 0, sizeof(num)); for(int i = 0; i <n ;i++) { scanf("%s", a); trans(a); add(num, a); } trans(num); len = strlen(num); int i; for(i = 0; i < len; i++) if(num[i] != '0') break; if(i == len) printf("0"); else for(;i < len; i++) printf("%c", num[i]); printf("\n"); } return 0;}
0 0
- BestCoder #33 zhx's submissions
- BestCoder Round #33 1001 zhx's submissions
- BestCoder Round #33(zhx's submissions-手速题,注意判断00和0的情况)
- hdu5186 zhx's submissions
- hdu 5186 zhx's submissions
- HDU - 5186 zhx's submissions
- hdu 5186 zhx's submissions
- BestCoder Round #33 1002 zhx's contest
- hdu 5186 zhx's submissions(模拟)
- BestCoder Round #33(zhx's contest-快速乘法)
- 【CUGBACM15级BC第33场 A】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 ACM 5186 zhx's submissions
- hdu 5186 zhx's submissions 5187 zhx's contest快速幂小优化
- zhx's contest BestCoder Round #33(快速乘法+快速幂的原理)
- 个推运行环境
- 2014LuJW-Human Identity and Gender Recognition from Gait Sequences with Arbitrary Walking Directions
- Android程序的反破解技术
- google面试题,生男生女比例?
- 常用的dialog,包括:single Choice Dialog,Multiple choice Dialog,Input Dialog ,Progress Dialog....
- BestCoder #33 zhx's submissions
- android 获取手机的设备信息
- 支持Android iOS,firefox(其它未测)的图片上传客户端预览、缩放、裁切。
- UISearchBar 右边按钮自定义
- 快速求质数(C语言描述)
- NDK在windows下的开发环境搭建及开发过程
- LeetCode 006 ZigZag Conversion
- new和malloc的区别
- GDB调试命令学习