//Accepted zoj1530 270ms 40008KB #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; ; string a[imax_n]; int vis[imax_n]; queue<int > q; queue<string >sq; void bfs(int n) { if (a[n]!="") return ; while (!q.empty()) q.pop(); while (!sq.empty()) sq.pop(); q.push(); sq.push("); ) { int x=q.front(); q.pop(); string s=sq.front(); sq.pop(); ) { a[n]=s; return ; } q.push(*x%n); sq.push(s+"); q.push((*x+)%n); sq.push(s+"); } } int main() { int n; while (scanf("%d",&n),n) { bfs(n); cout<<a[n]<<endl; } ; }
//Accepted zoj1530 110ms 4544kB #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; ; long long a[imax_n]; queue<long long > q; void bfs() { ; while (!q.empty()) q.pop(); q.push(); ) { long long x=q.front(); q.pop(); ;i<=;i++) && x%i==) { a[i]=x; cnt++; } ) return ; q.push(*x); q.push(*x+); } } int main() { bfs(); int n; //for (int i=1;i<=200;i++) //{ // printf("a[%d]=%lld\n",i,a[i]); //} while (scanf("%d",&n),n) { printf("%lld\n",a[n]); } ; }