QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#695006#6728. To the ParkShuishui#WA 259ms4488kbC++141.4kb2024-10-31 19:07:092024-10-31 19:07:09

Judging History

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

  • [2024-10-31 19:07:09]
  • 评测
  • 测评结果:WA
  • 用时:259ms
  • 内存:4488kb
  • [2024-10-31 19:07:09]
  • 提交

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;
				}			
			}
		}

	}
	// 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: 3632kb

input:

3
1
4
6

output:

0
1 4 2
2 4 2 6 3

result:

ok 4 cases

Test #2:

score: -100
Wrong Answer
time: 259ms
memory: 4488kb

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 4 2
1 4 2
2 4 2 6 3
2 4 2 6 3
2 4 2 6 3
2 4 2 6 3
3 4 2 6 3 10 5
3 4 2 6 3 10 5
3 4 2 6 3 10 5
3 4 2 6 3 10 5
4 4 2 6 3 10 5 14 7
4 4 2 6 3 10 5 14 7
5 4 2 6 3 10 5 14 7 16 8
5 4 2 6 3 10 5 14 7 16 8
6 4 2 6 3 10 5 14 7 16 8 18 9
6 4 2 6 3 10 5 14 7 16 8 18 9
6 4 2 6 3 10 5 14 7 16 8 18 9
6 ...

result:

wrong answer Case #9: Participant has a worse answer