Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a number which in d
2016-10-13 00:43
1386 查看
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
Sample Output
#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;
}
of n?
Sample Input
3 7 9901
Sample Output
3 6 12
#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;
}
相关文章推荐
- Given an array of size N in which every number is between 1 and N, determine if there are any dupli
- 异常-----Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string.\u003Cformat> or ?string(format) built-
- Your task is to find for a given phone number any of its divisions into groups of two or three digit
- error C2679: binary '<<' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion
- 'ddlXXX' has a SelectedIndex which is invalid because it does not exist in the list of items
- WCF:Maximum number of items that can be serialized or deserialized in an object graph is '65536'.
- One of the disks in this virtual machine is already in use by a virtual machine or by a snapshot"
- Serial number is not available when doing any inventory transaction but shows in on hand quantity in
- 'ddlCities' has a SelectedValue which is invalid because it does not exist in the list of items
- Oracle Database does not provide any supplemental logging, which means that by default LogMiner is not usable
- How To Check Whether Physical Standby is in Sync with the Primary or Not?
- this may be due to a corruption of the heap, which indicates a bug in ... or any of the DLLs it has
- [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c
- org.springframework.dao.InvalidDataAccessApiUsageException: ERR value is not an integer or out of ra
- 在 12cR1 数据库中创建测试用户是报 ORA-65096 错误(2c: ORA-65049: creation of local user or role is not allowed in C)
- FAT file system-Given any valid cluster number N, where in the FAT(s) is the entry for that cluster number?
- How to arrange 10 digits so that the product of the some of them is equal to a number represented by the remaining digits
- This may be due to a corruption of the heap, which indicates a bug in *.exe or any of the DLLs it has loaded.
- Adobe--Without using /,% ,+and * operators. write a function to check whether a number is divisible by 3 or nor?
- [mysql] Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'loser.tank_admin.login_ip' which is not functionally dependent on columns in GROUP BY clause; this is