Link: Ultraviolet A 1350-Pinary
N is given, n is output to Pinary Number, and Pinary Number is binary, and there is no continuous connection between two 1 s.
Solution: dp [I] indicates that there are dp [I] types in the I-th bit. Therefore, if a layer of n is given and the dp [I] is less than or equal to n, 1 is output, n minus dp [I]. Note that leading 0 cannot be output when 0 is output.
# Include
# Include
Typedef long ll; const int N = 50; ll dp [N]; void init () {memset (dp, 0, sizeof (dp )); dp [0] = dp [1] = 1; for (int I = 2; I <= 40; I ++) dp [I] = dp [I-1] + dp [I-2];} void solve (ll n) {bool flag = false; for (int I = 40; I --) {if (n> = dp [I]) {printf ("1"); n-= dp [I]; flag = true;} else if (flag) printf ("0");} printf ("\ n");} int main () {init (); int cas; ll n; scanf ("% d ", & cas); for (int I = 0; I <cas; I ++) {scanf ("% lld", & n); solve (n );} return 0 ;}