题意:输入 a,输出最小的 n 个 1 组成的数,使这个数能整除 a(如果存在)。
思路:不断对余数乘以 10+1,直到余数已经出现停止(不存在),或者能整除(存在)。
#include<iostream>
#include<cmath>
#include<queue>
#include<cstring>
#include<string>
#include<map>
#include<stack>
#include<set>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[1000005], n;
int main(){
//freopen("a.txt", "r", stdin);
while(scanf("%d", &n) != EOF){
memset(a, 0, sizeof(a));
int ans = 1;
int cnt = 1;
int flag = 0;
while(ans%n != 0){
int t = ans%n;
cnt++;
ans = t*10+1;
if(a[t]){
flag = 1;
break;
}
a[t] = 1;
}
if(flag) cout << "There is no Singles' Day!" << endl;
else{
cout << "Singles' Day is on ";
for(int i = 0; i < cnt; i++) cout << "1";
cout << "." <<endl;
}
}
return 0;
}