poj 百练2972(基础题)
来源:互联网 发布:企业起名软件 编辑:程序博客网 时间:2024/05/17 07:50
参考例程代码
例子确实写的好
关键:其他进制数据转换为10进制 b2ten()
#include <stdio.h>#include <string.h>long b2ten(char *x, int b){int ret = 0;int len = strlen(x);for (int i = 0; i < len; ++i){if(x[i] - '0' >= b)return -1;ret *= b;ret += x[i] - '0';}return (long)ret;}int main(){int T;int i,j;char p[8],q[8],r[8];long palgo,qalgo,ralgo;scanf("%d",&T);while(T--){scanf("%s%s%s",&p,&q,&r);int b;for(b = 2; b <= 16; ++b){palgo = b2ten(p,b);qalgo = b2ten(q,b);ralgo = b2ten(r,b);if(palgo == -1 || qalgo == -1 || ralgo == -1)continue;if(palgo * qalgo == ralgo){printf("%d\n",b);break;}}if(b == 17)printf("0\n");}return 0 ;}
- poj 百练2972(基础题)
- poj 百练(2735)基础题
- poj 百练2974(基础题)
- poj 百练2744( 基础题)
- poj 百练2975(基础题)
- poj 百练 2743(基础题)
- poj 百练 2976(基础题)
- poj 百练 2819(基础题)
- poj 百练2820(基础题)
- poj 百练 2797(基础题)
- poj 百练 2765(基础题)有难度
- poj 百练2973(基础题)
- poj 百练2734(基础题)
- poj 百练 2798(基础题)
- poj 百练 2742(基础题)
- poj 百练2799(基础题)
- C语言I/O小结 poj百练2804字典(基础题)
- POJ 百练 2972: 确定进制
- XCode快捷键
- C中的宏定义
- 每天计划
- 第八周任务三(实现分数类中的运算符重载)
- sizeof的用法
- poj 百练2972(基础题)
- RadTreeView 加上CheckbOX
- SAX、DOM、PULL解析XML
- interview
- C/C++通过WMI和系统API函数获取获取系统硬件(cpu,内存,显卡,网卡)配置信息
- 将小写字母转换为大写字母
- OK6410编译U_BOOT,使之支持DM9000AE(一)
- 当你输入一个网址的时候,实际会发生什么?
- 详细的单链表基本操作C/C++实现