UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#202110#2784. 01串Anonyme100368ms1616kbC++11766b2024-02-12 08:43:412024-02-12 18:48:42

answer

#include <bits/stdc++.h>
using namespace std;

#define QwQ330AwA return 0
#define ll long long

ll C(int n) {
	return 1ll * n * (n - 1) / 2;
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int len = 1;
		while (C(len) < n) len++;
		n = C(len) - n;
		int sum = 0;
		vector <int> pos;
		for (int i = len; i >= 1; i--) {
			while (sum + i <= len && C(i) <= n) {
				n -= C(i);
				sum += i;
				pos.push_back(i);
			}
			if (!n) break;
		}
		while (sum < len) pos.push_back(1), sum++;
		int op = 1;
		for (auto x : pos) {
			if (op) {
				while (x--) cout << '0';
			} else {
				while (x--) cout << '1';
			}
			op ^= 1;
		}
		cout << '\n';
	}
	QwQ330AwA;
}

Details

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 8
Accepted

Test #1:

score: 8
Accepted
time: 0ms
memory: 1236kb

input:

500
13
7
6
20
1
18
17
19
9
15
10
12
9
8
11
15
3
14
7
9
7
17
16
19
18
7
11
14
6
5
17
3
11
7
2
20
7
7
...

output:

001101
00010
0101
0010101
01
0001010
0001101
0011010
00101
010101
01010
000101
00101
00110
000110
01...

result:

points 1.0 Accepted

Subtask #2:

score: 21
Accepted

Test #2:

score: 21
Accepted
time: 0ms
memory: 1240kb

input:

500
933
647
306
780
621
898
757
879
89
95
790
72
469
828
171
515
623
934
687
589
147
417
816
939
758...

output:

00000111010101010101010101010101010101010101
0000001110010101010101010101010101010
00000011100101010...

result:

points 1.0 Accepted

Subtask #3:

score: 23
Accepted

Test #3:

score: 23
Accepted
time: 3ms
memory: 1240kb

input:

500
84933
1647
40306
72780
90621
15898
73757
86879
66089
93095
5790
43072
69469
44828
60171
14515
68...

output:

0000000000000000011110001010101010101010101010101010101010101010101010101010101010101010101010101010...

result:

points 1.0 Accepted

Subtask #4:

score: 48
Accepted

Test #4:

score: 48
Accepted
time: 365ms
memory: 1616kb

input:

500
253484933
463401647
466040306
780172780
189090621
382815898
292073757
119686879
18566089
2984930...

output:

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 Accepted

Extra Test:

score: 0
Extra Test Passed