您的位置:首页 > 其它

UVa Problem 10127 Ones (仅由 1 组成的数)

2011-05-29 16:34 405 查看
// Ones (仅由 1 组成的数)
// PC/UVa IDs: 110504/10127, Popularity: A, Success rate: high Level: 2
// Verdict: Accepted
// Submission Date: 2011-05-29
// UVa Run Time: 0.008s
//
// 版权所有(C)2011,邱秋。metaphysis # yeah dot net
//
// 利用求模运算。(x * y + 1) mod n = ((x mod n) * (y mod n) + (1 mod n)) mod n。

#include <iostream>

using namespace std;

int main(int ac, char *av[])
{
int number;

while (cin >> number)
{
long long start = 1;
int counter = 1;
while (start % number)
{
start = (start % number) * (10 % number) + 1;
counter++;
}

cout << counter << endl;
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: