QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#595275#9354. Justifying the Conjectureyeah14TL 58ms23888kbC++171.5kb2024-09-28 13:15:032024-09-28 13:15:03

Judging History

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

  • [2024-09-28 13:15:03]
  • 评测
  • 测评结果:TL
  • 用时:58ms
  • 内存:23888kb
  • [2024-09-28 13:15:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ull long long
#define PII  pair<int ,int>
const int INF = -1145141919810;
const int mod = 1e9 + 7;
const int N = 1e7;
int a[N];
int sum[N];
int fa[N];
int ka[N];
vector<int>pr;
bool vis[N];
void er(int n) {
	int cnt = 0;
	memset(vis, 0, sizeof(vis));
	for (int i = 2; i <= n; i++) {
		if (!vis[i])pr.push_back(i);
		for (int j = 0; j < pr.size(); j++) {
			if (i * pr[j] > n)break;
			vis[i * pr[j]] = 1;
			if (i * pr[j] == 0)break;
		}
	}
}
int is_p(int x) {
	if (x == 1)return 1;
	for (int i = 0; i < pr.size(); i++) {
		if (x == pr[i])return 1;
		if (x % pr[i] == 0)return 0;
		if (pr[i] > x)break;
	}
	return 1;
}


void solve() {
	int n;
	cin >> n;
	for (int i = 0; i < pr.size(); i++) {
		int a = pr[i], b = n - a;
		if (is_p(b) == 0) {
			cout << a << " " << b << endl;
			return ;
		}
	}
	cout << -1 << endl;	
}
//&&(((sum[n]+k)%mid==0)||(sum[n]/mid!=(sum[n]+k)/mid)||(mid-(sum[n]%mid)>=k))
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	cin >> t;
	//t = 1;
	er(9e6);
	while (t--)solve();
	
}
//int n;
//cin >> n;
//for (int i = 1; i <= n; i++) {
//	cin >> a[i];
//}
//int maxx = 0, minn = INF;
//int sum = 0;
//for (int i = n; i <= 1; i++) {
//	sum += minn;
//	if (top == 0) {
//		minn = a[i];
//		st[top++] = a[i];
//	}
//	else {
//		if (a[i] > top && a[i] > minn)
//	}
//}
//cout << maxx - minn << endl;
//7 2 1 4 5 1 3 3
//4 1000 1000 1000 1000
//0

詳細信息

Test #1:

score: 100
Accepted
time: 58ms
memory: 23888kb

input:

3
4
6
7

output:

-1
2 4
3 4

result:

ok ok

Test #2:

score: -100
Time Limit Exceeded

input:

100000
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
8...

output:

3 -2
2 0
3 0
-1
5 0
2 4
3 4
2 6
3 6
2 8
2 9
2 10
3 10
2 12
3 12
2 14
2 15
2 16
3 16
2 18
3 18
2 20
2 21
2 22
3 22
2 24
2 25
2 26
2 27
2 28
3 28
2 30
3 30
2 32
2 33
2 34
2 35
2 36
3 36
2 38
2 39
2 40
3 40
2 42
3 42
2 44
2 45
2 46
3 46
2 48
2 49
2 50
2 51
2 52
3 52
2 54
2 55
2 56
2 57
2 58
3 58
2 60
3...

result: