FZU Problem 2102 Solve equation (数学啊 )
来源:互联网 发布:ubuntu 文件编辑器 编辑:程序博客网 时间:2024/06/04 18:30
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2102
Problem Description
You are given two positive integers A and B in Base C. For the equation:
We know there always existing many non-negative pairs (k, d) that satisfy the equation above. Now in this problem, we want to maximize k.
For example, A="123" and B="100", C=10. So both A and B are in Base 10. Then we have:
(1) A=0*B+123
(2) A=1*B+23
As we want to maximize k, we finally get one solution: (1, 23)
The range of C is between 2 and 16, and we use 'a', 'b', 'c', 'd', 'e', 'f' to represent 10, 11, 12, 13, 14, 15, respectively.
Input
The first line of the input contains an integer T (T≤10), indicating the number of test cases.
Then T cases, for any case, only 3 positive integers A, B and C (2≤C≤16) in a single line. You can assume that in Base 10, both A and B is less than 2^31.
Output
Sample Input
Sample Output
Source
“高教社杯”第三届福建省大学生程序设计竞赛题意:
给出 A 和 B 求满足 A = k * B + d,的最大的K;
c表示A, 和B是几进制!
代码如下:
#include <cstdio>#include <cstring>int main(){ int t; int cas = 0; int c; char a[47], b[47]; scanf("%d",&t); while(t--) { int t1 = 0, t2 = 0; scanf("%s%s%d",a,b,&c); int len1 = strlen(a); int len2 = strlen(b); for(int i = 0; i < len1; i++) { t1 *= c; if(a[i]<='9' && a[i]>='0') t1+=a[i]-'0'; else t1+=a[i]-'a'+10; } for(int i = 0; i < len2; i++) { t2 *= c; if(b[i]<='9' && b[i]>='0') t2+=b[i]-'0'; else t2+=b[i]-'a'+10; } printf("(%d,%d)\n",t1/t2,t1%t2); } return 0;}
- FZU Problem 2102 Solve equation (数学啊 )
- FZU Problem 2102 Solve equation
- FZU Problem 2102 Solve equation题解
- FZU 2102 Solve equation
- FZU 2102 Solve equation
- FZU - 2102 Solve equation
- FZU-2102-Solve equation
- FZU 2102Solve equation
- fzu 2102 Solve equation(水题)
- FZU - 2102 Solve equation(水题)
- FZU 2102 Solve equation (水)
- FZU 2102 Solve equation(规律题)
- F Solve equation(FZU 2102)
- 【水】FZU 2102 Solve equation
- FZU 2102 Solve equation (进制转换)
- FZU Problem 2102 Solve equation 第三届福建省大学生程序设计竞赛
- FZU Problem 2110 Star (数学啊 )
- FZU Problem 2104 Floor problem (数学啊 )
- Linux之Makefile(Makefile规则例子)
- 用Eclipse 开发Flex (配置安装Flex插件)
- 探索测试
- C语言如何清除scanf()缓存
- Android Read FileNotFoundException
- FZU Problem 2102 Solve equation (数学啊 )
- FFmpeg+SDL视频播放(1)
- 开发者必备的SQL性能优化基本功
- 蚂蚁的难题(X)
- N个数的全排列
- 第十五周上机项目3--(4) 指针戏虐
- ORM
- 利用MalwareDefender保障系统安全
- VB程序逆向反汇编常见的函数