Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a number which in d
来源:互联网 发布:外交部霸气发言知乎 编辑:程序博客网 时间:2024/06/05 02:32
Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a number which in decimal notation is a sequence of 1's. How many digits are in the smallest such a multiple of n?
Sample Input
3 7 9901
Sample Output
3612
#include<iostream>
using namespace std;
int main()
{
int n;
while (cin >>n &&n!=EOF)
{
int ans = 1;
int m = 1;
while (m %= n) (注意while括号中的表达式已经能表示一个值是否存在,是否有意义,不需要再写出while(m%n==0)这样写当值大到一定程度时会输不出结果 ,运行时间需要的太长了)
{
m =m * 10 + 1;
ans++;
;
}
cout <<ans<<endl;
}
return 0;
}
0 0
- Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a number which in d
- Given an array of size N in which every number is between 1 and N, determine if there are any dupli
- Find whether a given number is a power of 4 or not
- fatal: Not a git repository (or any of the parent&n
- Given a positive integer N, you should output the most right digit of N^N.
- FAT file system-Given any valid cluster number N, where in the FAT(s) is the entry for that cluster number?
- Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
- 题目描述 Given n points on a 2D plane, find the maximum number of points that lie on the same straight
- Leetcode--->Given n points on a 2D plane, find the maximum number of points that lie on the same str
- how many positive integers are divisible by a number d in range [x,y]?
- Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or
- The number of nodes within k-hops in a n-D Torus
- complexity of judging n numbers is sorted or not
- CareerCup Find whether a given number is a perfect square or not.(Addition and Subtraction only)
- Find a number in the array having least difference with the given number (n)
- n is a power of 2 ?
- P31 (**) Determine whether a given integer number is prime.
- Searching: Fibonaccian Search-2: N+1 is NOT a perfect Fibonacci number
- HDU 1712 ACboy needs your help (分组背包 每组至多选一个)
- CSS3.0动画兼容模板
- AJAX的一些相关知识
- C/C++中main()格式
- C/C++ Windows API——获取系统指定目录
- Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a number which in d
- 日志收集平台Graylog2以及Nxlog的安装与配置(基于docker)
- 用户通信程序
- 通过for循环 ,画出一个正方形、正三角形
- raw_input()与sys.stdin.readline()的区别
- 116.Jump Game-跳跃游戏(中等题)
- 点击弹出一个面板代码示例
- JavaScript的函数的使用
- Centos 7下安装配置VPN服务器