Uva 550 Multiplying by Rotation(模拟乘法)
2017-08-11 09:38
344 查看
题意:
给出进制,某个数的最后一位,还有乘数,求这个数的位数。我直接举个例子abc4*7=4abc。进制10,数的最后一位为4,乘数为7.因为4*7=28,所以c为8,又4*8=32,所以b为4,这样一直推下去直到4,且没有进位就结束。
#include<iostream>
using namespace std;
int main()
{
int sys,e,s;
while(scanf("%d %d %d",&sys,&e,&s)!=EOF){
int te=0,es,co=0,ju=e;
while(1){
co++;
es=e*s;
if((es+te)==ju) break;
e=(es+te)%sys;
te=(es+te)/sys;
}
printf("%d\n",co);
}
return 0;
}
给出进制,某个数的最后一位,还有乘数,求这个数的位数。我直接举个例子abc4*7=4abc。进制10,数的最后一位为4,乘数为7.因为4*7=28,所以c为8,又4*8=32,所以b为4,这样一直推下去直到4,且没有进位就结束。
#include<iostream>
using namespace std;
int main()
{
int sys,e,s;
while(scanf("%d %d %d",&sys,&e,&s)!=EOF){
int te=0,es,co=0,ju=e;
while(1){
co++;
es=e*s;
if((es+te)==ju) break;
e=(es+te)%sys;
te=(es+te)/sys;
}
printf("%d\n",co);
}
return 0;
}
相关文章推荐
- UVa 550 Multiplying by Rotation (模拟乘法)
- uva 550 Multiplying by Rotation(模拟)
- UVa 550 - Multiplying by Rotation
- UVA - 550 Multiplying by Rotation
- UVA-550 Multiplying by Rotation
- UVA - 550 Multiplying by Rotation
- UVA 550 Multiplying by Rotation (简单递推)
- UVa 550 Multiplying by Rotation
- UVA 550 (暑假-数论 -B - Multiplying by Rotation)
- UVA - 550 Multiplying by Rotation
- UVA - 550 Multiplying by Rotation
- UVa 550 - Multiplying by Rotation
- UVa 550 Multiplying by Rotation
- UVa 550: Multiplying by Rotation
- UVA550 Multiplying by Rotation
- UVa 550 - Multiplying by Rotation
- uva 550 - Multiplying by Rotation
- Uva 550 - Multiplying by Rotation
- UVA 550 - Multiplying by Rotation
- UVa550 Multiplying by Rotation