QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#694972#6728. To the ParkShuishui#WA 26ms4468kbC++141.6kb2024-10-31 19:03:132024-10-31 19:03:14

Judging History

你现在查看的是最新测评结果

  • [2024-10-31 19:03:14]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:4468kb
  • [2024-10-31 19:03:13]
  • 提交

answer

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

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define Sz(x) (int)(x).size()
#define bit(x) (1ll << (x))
using ll = long long;
using db = double;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vd = vector<db>;
mt19937 mrand(time(0));

void solve(void)
{
	int n;
	cin >> n;
	vi vis(n + 2);
	vector<array<int, 2>> ans;
	for (int i = 2; i <= n; i++) if (!vis[i])
	{
		// int bd = 0;
		// for (int d = 2; d * d <= i; d++)
		// {
		// 	bd = d;
		// 	if (i % d == 0 && !vis[i / d])
		// 	{
		// 		ans.pb({i, i / d});
		// 		vis[i] = vis[i / d] = 1;
		// 		break;
		// 	}
		// }

		// if (!vis[i])
		// {
		// 	for (int d = bd; d >= 2; d--)
		// 	{
		// 		// cerr << i << " " << d << "\n";
		// 		if (i % d == 0 && !vis[d])
		// 		{
		// 			ans.pb({i, d});
		// 			vis[i] = vis[d] = 1;
		// 			break;
		// 		}			
		// 	}
		// }
		for (int j = 2; j * i <= n; j++)
			if (!vis[j * i])
			{
				vis[i] = vis[j * i] = 1;
				ans.pb({i, j * i});
				break;
			}
	}
	// cerr << "GG\n";

	int m = Sz(ans);
	cout << m << " \n"[m == 0];
	for (int i = 0; i < m; i++)
		cout << ans[i][0] << " " << ans[i][1] << " \n"[i == m - 1];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// cout << fixed << setprecision(10);

	int T = 1;
	cin >> T;
	for (int i = 1; i <= T; i++)
	solve();

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3912kb

input:

3
1
4
6

output:

0
1 2 4
2 2 4 3 6

result:

ok 4 cases

Test #2:

score: -100
Wrong Answer
time: 26ms
memory: 4468kb

input:

1007
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101...

output:

0
0
0
1 2 4
1 2 4
2 2 4 3 6
2 2 4 3 6
2 2 4 3 6
2 2 4 3 6
3 2 4 3 6 5 10
3 2 4 3 6 5 10
3 2 4 3 6 5 10
3 2 4 3 6 5 10
4 2 4 3 6 5 10 7 14
4 2 4 3 6 5 10 7 14
5 2 4 3 6 5 10 7 14 8 16
5 2 4 3 6 5 10 7 14 8 16
6 2 4 3 6 5 10 7 14 8 16 9 18
6 2 4 3 6 5 10 7 14 8 16 9 18
6 2 4 3 6 5 10 7 14 8 16 9 18
6 ...

result:

wrong answer Case #9: Participant has a worse answer