virtual hust 2013.6.20 数论基础题目 C - Multiplying by Rotation

题目: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\n",ans);
    }
    return 0;
}
View Code
复制代码

 

posted @ 2013-06-21 00:28  over_flow  阅读(126)  评论(0)    收藏  举报
编辑推荐:
· 一个字符串替换引发的性能血案:正则回溯与救赎之路
· 为什么说方法的参数最好不要超过4个?
· C#.Net 筑基-优雅 LINQ 的查询艺术
· 一个自认为理想主义者的程序员,写了5年公众号、博客的初衷
· 大数据高并发核心场景实战,数据持久化之冷热分离
阅读排行:
· 发布一个小功能,通过 markdown 图片语法嵌入B站视频
· 《HelloGitHub》第 111 期
· 谷歌新AI工具杀疯了?免费,但有点坑!Gemini CLI 抢先实测
· 使用GcExcel .NET将Excel导出为PDF
· MySQL 字符集、排序规则与查询关系详解
点击右上角即可分享
微信分享提示