|
- #include <algorithm>
- #include <iostream>
- #include <cmath>
- #include <cstring>
- #include <map>
- #include <string>
- #include <vector>
- #include <queue>
- #include <stack>
- #include <cstdio>
- #include <cstdlib>
- using namespace std;
- long long x,n,c[20],m;
- void dfs(long long w,long long all)
- {
- if(w==1)
- {
- if(all%n==0)
- m=all/n;
- return;
- }
- if(!m) dfs(w-1,all);
- if(!m) dfs(w-1,all+c[w-1]);
- }
- int main()
- {
- scanf("%lld",&n);
- for(long long i=1,j=1;i<=19;i++,j*=10)
- c[i]=j;
- dfs(19,0);
- if(!m) dfs(19,1000000000000000000);
- if(m)
- printf("%lld",m);
- else
- printf("No Solution");
- return 0;
- }
复制代码 |
|