UVA550把数字的最后移到最前面求这样的数字的长度

还是看不懂题意的问题,看着数据猜题意猜了好久没有猜出来,其实就是把一串数字的最后一位移到最前面,

写一下十进制的乘法可以同理的出来其他进制的乘法,设原来的数字为s,最后一位为b,则s*c的最后一位

s*c%a,其实是s倒过来那个数的第二位,然后依此类推,知道乘积+原来的进位==最低位。

#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<set>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
#include<memory>
#include<climits>
#include<cstdlib>
using namespace std;
#define LL long long
#define INT (1<<31)-1;
LL a[10][105],b[10][105];
int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
       int ans=b*c%a;
       int temp=b*c/a;
       int len=1;
      /* while(ans!=b||temp)
       {
           int tt=ans*c+temp;
           temp=tt/a;
           ans=tt%a;
           len++;
       }*/
       int s=b*c;
       while(s!=b)
       {
           s=s%a*c+s/a;
           len++;
       }
       cout<<len<<endl;
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值