当前位置:网站首页>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; }
边栏推荐
- kubernetes集群之调度系统
- 【thingsboard】替换首页logo的方法
- The development of mobile IM based on TCP still needs to keep the heartbeat alive
- Threejs implements labels and displays labels with custom styles
- What is the reason why the webrtc protocol video cannot be played on the easycvr platform?
- Plasticscm enterprise crack
- 10种寻址方式之间的区别
- FFmepg使用指南
- How to solve the problem that easycvr changes the recording storage path and does not generate recording files?
- 如何优雅的获取每个分组的前几条数据
猜你喜欢

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

Plasticscm enterprise crack

Technical tutorial: how to use easydss to push live streaming to qiniu cloud?

【虚幻引擎UE】实现背景模糊下近景旋转操作物体的方法及踩坑记录

How does the applet solve the rendering layer network layer error?

UI自动化测试从此告别手动下载浏览器驱动

Use of vscode software

Kwai, Tiktok, video number, battle content payment

如何实现实时音视频聊天功能

【看完就懂系列】一文6000字教你从0到1实现接口自动化
随机推荐
线上故障突突突?如何紧急诊断、排查与恢复
Wechat applet development process (with mind map)
如何实现实时音视频聊天功能
Rome chain analysis
The new project Galaxy token just announced by coinlist is gal
为什么百度、阿里这些大厂宁愿花25K招聘应届生,也不愿涨薪5K留住老员工?
Open graph protocol
Summary of scene design
DFS and BFS concepts of trees and graphs
[wp][introduction] brush weak type questions
【UNIAPP】系统热更新实现思路
About the project error reporting solution of mpaas Pb access mode adapting to 64 bit CPU architecture
Alibaba cloud ECS uses cloudfs4oss to mount OSS
kubernetes集群之调度系统
行为感知系统
测试开发是什么?为什么现在那么多公司都要招聘测试开发?
IronXL for . NET 2022.6
优先使用对象组合,而不是类继承
C language course setting: cinema ticket selling management system
EasyCVR更改录像存储路径,不生成录像文件如何解决?