NEU 1681: The Singles
阅读原文时间:2023年07月11日阅读:1

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
#include
#include
#include
#include
#include
#include
#include
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 1001000
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ; const double eps=1e-; using namespace std; priority_queue,greater >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
};

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 ;
}

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章