UESTC 1012 Ladygod (多校联盟3)
来源:互联网 发布:东方网络千股千评 编辑:程序博客网 时间:2024/05/28 15:40
题目地址:http://acm.uestc.edu.cn/#/problem/show/1012
思路:4位相加最多只会产生5位数,进制越低,位数越长
AC代码:
#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <queue>#include <stack>#include <map>#include <cstring>#include <climits>#include <cmath>#include <cctype>const int inf = 0x3f3f3f3f;//1061109567typedef long long ll;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;int a[5],b[5],c[5];int main(){ int t; scanf("%d",&t); while(t--) { int x,y; scanf("%d%d",&x,&y); memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0,sizeof(c)); int len1 = 0; int len2 = 0; int p = 0; while(x) { a[len1++] = x % 10; x /= 10; p = max(p,a[len1-1]); } while(y) { b[len2++] = y % 10; y /= 10; p = max(p,b[len2-1]); } p++; int k = 0; for(int i=0; i<5; i++) { c[i] = (a[i] + b[i] + k) % p; k = (a[i] + b[i] + k) / p; } for(int i=4; i>=0; i--) { if(c[i]) { printf("%d\n",i+1); break; } } } return 0;}
0 0
- UESTC 1012 Ladygod (多校联盟3)
- UESTC - 1012 Ladygod (模拟)
- UESTC--1012--Ladygod(模拟水题)
- UESTC 1012:Ladygod【模拟】
- UESTC 1012 Ladygod
- UESTC 1012-Ladygod【没有负数】
- Ladygod UESTC
- UESTC 1271 Search gold (DP,多校联盟3)
- UESTC 1012 Ladygod【进制转换】
- UESTC 1012 Ladygod 任意进制的转化
- 多校联盟-()
- 巴什博奕(多校联盟六)
- 2015多校联盟
- 多校联盟#con1 数学题
- Light Oj 1319 - Monkey Tradition(多校联盟3,中国剩余定理)
- HDU6098 Inversion -2017多校联盟6 第3题
- #con5多校联盟 (李主席与阶乘)
- 暑假多校联盟(=) e题 书架
- Android总结 - Menu
- maven学习笔记 maven的使用
- Python笔记2
- linux下用live555进行二次开发指南
- iOS限制文本框输入两位小数和最大值
- UESTC 1012 Ladygod (多校联盟3)
- 项目9--求最大公约数
- 查看centos目录文件大小
- error: Error: No resource found for attribute ‘layout_scrollFlags’ in package‘包名’
- Python笔记3
- 泰坦尼克号
- J2EE --- forward VS redirect
- Criteria 的用法 (转)
- 图像的稀疏表示——ScSPM和LLC的总结