virtual hust 2013.6.20 数论基础题目 C

题目:Multiplying by Rotation

思路:求base进制下,长度最短的数字满足乘以factor,使得原来的最低位等于最高位。

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
    int base,first,factor;
    while(cin>>base>>first>>factor)
    {
        int now=first*factor;
        int ans=1;
        while(first!=now)
        {
            now=(now%base)*factor+now/base;
            ans++;
        }
        printf("%d
",ans);
    }
    return 0;
}
View Code
原文地址:https://www.cnblogs.com/overflow/p/3147500.html