1 #include<iostream> 2 #include<queue> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<cstring> 6 using namespace std; 7 queue <long long> q; 8 long long n; 9 long long tot; 10 char s[50]; 11 int main () 12 { 13 cin>>n; 14 q.push(1); 15 while (1) 16 { 17 long long x=q.front(); q.pop(); 18 if(x<0) 19 { 20 cout<<"no solution"; 21 return 0; 22 } 23 if (x%n==0) 24 { 25 cout<<x<<" "<<x/n; 26 return 0; 27 } 28 q.push(x*10); q.push(x*10+1); 29 } 30 }
原文:https://www.cnblogs.com/zjzjzj/p/11178155.html