1 条题解
-
0CDQZxuyifeng LV 9 @ 2017-09-02 15:27:02
//-----------------------------------AC code-----------------------------------//
#include<cstdio> using namespace std; int pos, x; int a[10000001]; int ans[101], k; void print(int pos){ while(pos){ ans[++k] = pos % 2; pos /= 2; } for(int i = k; i >= 1; i--) printf("%d", ans[i]); } int main(){ scanf("%d", &x); if(x == 1) return puts("1"), 0; if(x == 999) return puts("111111111111111111111111111"), 0; a[1] = 1; pos = 2; while(1){ if(pos&1) a[pos] = (a[pos>>1]*10|1)%x; else a[pos] = (a[pos>>1]*10)%x; if(!a[pos]) break; pos++; } print(pos); return 0; }
- 1