POJ 1331

/*
** 2015-09-19 09:27:58
**  POJ  1331  问题描述:数A 乘以数B 等于数C 其中 A、B、C 都可以用同一进制数表示 例如 6(13) *9 (13)=42(13),其中13位进制。判断一组数 a,b,c 符合条件的最** 小进制数

** by : 飞翔的黑珍珠

** 本人承诺以下代码均为本人亲自编写。

*/


/*
#include <iostream>


using namespace std;
int main()
{
int N ;
int p,q ,r;
int B;
int temp1 = 0;
int temp2 = 0;
int temp3 = 0;
bool flag = 0;
cin >>N;
while (N-- &&(cin >>p >>q >>r))
{
if ( (p >=1 && p <= 1000000) &&(q >=1 && q <= 1000000)&&(r >=1 && r <= 1000000))
{
int a[] ={r/100000,r%100000/10000,r%10000/1000,
r%1000/100,r%100/10,r%10,q/100000,
q%100000/10000,q%10000/1000,q%1000/100,
q%100/10,q%10,p/100000,p%100000/10000,
p%10000/1000,p%1000/100,p%100/10,p%10};

int max = 0;
for (int n = 0; n <18 ;n++)
{
if ( max < a[n])
{
max = a[n];
}
}
for ( B = max+1; B < 17 ;B++)
{
temp1 = a[0]*B*B*B*B*B+a[1]*B*B*B*B+a[2]*B*B*B+a[3]*B*B+a[4]*B+a[5];
temp2 = a[6]*B*B*B*B*B+a[7]*B*B*B*B+a[8]*B*B*B+a[9]*B*B+a[10]*B+a[11];
temp3 = a[12]*B*B*B*B*B+a[13]*B*B*B*B+a[14]*B*B*B+a[15]*B*B+a[16]*B+a[17];
if (temp1 == temp2*temp3)
{
flag = 1;
cout << B <<endl;
break;
}
temp1 = 0;
temp2 = 0;
temp3 = 0;
}

}
else
{
break;
}
if ( flag == 1)
{
flag = 0;
}
else
{
cout << "0" <<endl;
}
}
return 0;
}
*/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值