当前位置:网站首页>All in one 1413: determine base
All in one 1413: determine base
2022-07-05 04:10:00 【Studying hard】
【 Title Description 】
6×9=42 It's wrong for the decimal system , But for 13 It's correct in hexadecimal . namely , 6(13)× 9(13)= 42(13), and 42(13)=4×131+2×130=54(10).
Your task is to write a program , Read in three integers p、q and r, Then determine a base B(2<=B<=40) bring p × q = r. If B There are many options , Output the smallest one .
for example :p=11, q=11, r=121. Then there are 11(3)× 11(3)= 121(3) because 11(3)= 1 × 31+ 1 × 30= 4(10) and 121(3)=1×32+2×31+1×30=16(10). For hexadecimal 10, There are also 11(10)× 11(10)= 121(10). In this case , The output should be 3. If there is no suitable base , The output 0.
【 Input 】
a line , Contains three integers p、q、r. p、q、r All bits of are numbers , also 1 ≤ p、q、r ≤ 1,000,000.
【 Output 】
An integer : Even if have to p×q=r The smallest established B. If there is nothing suitable B, The output 0.
【 sample input 】
6 9 42【 sample output 】
13#include<stdio.h> #include<math.h> int getmin(int k,int j) { int temp; int i = 0; int count = 0; while (1) { temp = k % 10; count += temp * pow(j, i); i++; k /= 10; if (k == 0) { break; } } return count; } int main() { int m, n, k; scanf("%d%d%d", &m, &n, &k); int flag = 1; int num1, num2, num3; int j; for (j = 2; j <= 40; j++) { num1 = getmin(m, j); num2 = getmin(n, j); num3 = getmin(k, j); if (num1 * num2 == num3) { flag = 0; break; } } if (flag == 1) { printf("0"); } else { printf("%d", j); } return 0; }
边栏推荐
- 如何优雅的获取每个分组的前几条数据
- 3. Package the bottom navigation tabbar
- Learning MVVM notes (1)
- mysql的七种join连接查询
- 根据入栈顺序判断出栈顺序是否合理
- Longyuan war "epidemic" 2021 network security competition web easyjaba
- @The problem of cross database query invalidation caused by transactional annotation
- Use threejs to create geometry and add materials, lights, shadows, animations, and axes
- Threejs realizes sky box, panoramic scene, ground grass
- MacBook安装postgreSQL+postgis
猜你喜欢

Fuel consumption calculator

NEW:Devart dotConnect ADO. NET

技术教程:如何利用EasyDSS将直播流推到七牛云?

Pyqt5 displays file names and pictures

快手、抖音、视频号交战内容付费

error Couldn‘t find a package. JSON file in "your path“

Use threejs to create geometry, dynamically add geometry, delete geometry, and add coordinate axes

3. Package the bottom navigation tabbar

【thingsboard】替换首页logo的方法

【虚幻引擎UE】打包报错出现!FindPin错误的解决办法
随机推荐
快手、抖音、视频号交战内容付费
Threejs rendering obj+mtl model source code, 3D factory model
This article takes you to understand the relationship between the past and present of Bi and the digital transformation of enterprises
About the project error reporting solution of mpaas Pb access mode adapting to 64 bit CPU architecture
Online sql to excel (xls/xlsx) tool
provide/inject
Scheduling system of kubernetes cluster
长度为n的入栈顺序的可能出栈顺序种数
优先使用对象组合,而不是类继承
线上故障突突突?如何紧急诊断、排查与恢复
阿里云ECS使用cloudfs4oss挂载OSS
灵魂三问:什么是接口测试,接口测试怎么玩,接口自动化测试怎么玩?
C language course setting: cinema ticket selling management system
我国算力规模排名全球第二:计算正向智算跨越
FFmepg使用指南
Judge whether the stack order is reasonable according to the stack order
Pyqt5 displays file names and pictures
Un réveil de l'application B devrait être rapide
在线文本行固定长度填充工具
Bit operation skills