The Signals’ Day has passed for a few days. Numerous sales promotion campaigns on the shopping sites make us forget that 11.11 is the Signals’ Day. So we should do something to enhance the concept of Singles’ Day.
Let’s give a number a, you should find the minimum number n only consist of digit 1(ie. 111,11111…) which can be divided by a. If the number exist, you should output "Singles' Day is on n.", otherwise you should output "There is no Singles' Day!".
Several test cases.
For each test case:
Input is a integer a(1<=a<=1000000),as described above.
For each test case:
Output "Singles' Day is on n." or "There is no Singles' Day!" in one line.
1
2
3
Singles' Day is on 1.
There is no Singles' Day!
Singles' Day is on 111.
题目的意思就是 找到 一个只由1组成的数x 使得 x%a==0
一开始是这么 做得枚举 x 然后判断是否能被a整除。结果 wa了。
得用高精度做。从左边模拟每一位1除以a 具体看代码
/* ***********************************************
Author :guanjun
Created Time :2016/3/5 11:58:53
File Name :neu1681.cpp
************************************************ */
#include
#include
#include
#include
#include
#include
#include
#include
#include
bool cmp(int a,int b){
return a>b;
}
int mp[maxn];
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
ll a;
while(cin>>a){
cle(mp);
int num=;
int n=;
while(){
num++;
n=n%a;
if(n==){
printf("Singles' Day is on ");
for(int i=;i<=num;i++){
printf("");
}
printf(".\n");
break;
}
if(mp[n]){
puts("There is no Singles' Day!");break;
}
else mp[n]=;
n=n*+;
}
}
return ;
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章