QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#386306#1863. Yes, Prime MinisterKevin5307WA 1035ms150224kbC++231.4kb2024-04-11 15:11:052024-04-11 15:11:06

Judging History

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

  • [2024-04-11 15:11:06]
  • 评测
  • 测评结果:WA
  • 用时:1035ms
  • 内存:150224kb
  • [2024-04-11 15:11:05]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
bool isp[30003000];
int nxt[30003000];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	memset(isp,1,sizeof(isp));
	isp[0]=isp[1]=0;
	for(int i=2;i<30003000;i++)
		for(int j=i+i;j<30003000;j+=i)
			isp[j]=0;
	for(int i=30000000;i>=0;i--)
		if(isp[i])
			nxt[i]=i;
		else
			nxt[i]=nxt[i+1];
	int t;
	cin>>t;
	while(t--)
	{
		int x;
		cin>>x;
		if(x<=0)
		{
			x*=-1;
			if(isp[x+1])
				cout<<x+x+2<<'\n';
			else if(isp[x+1+x+2])
				cout<<x+x+3<<'\n';
			else
			{
				int y=nxt[x+1];
				cout<<y+y<<'\n';
			}
		}
		else
		{
			if(isp[x])
				cout<<1<<'\n';
			else if(isp[x+x-1]||isp[x+x+1])
				cout<<2<<'\n';
			else
			{
				int y=nxt[x];
				cout<<y+y<<'\n';
			}
		}
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1035ms
memory: 150224kb

input:

10
-2
-1
0
1
2
3
4
5
6
7

output:

6
4
3
2
1
1
2
1
2
1

result:

ok 10 numbers

Test #2:

score: -100
Wrong Answer
time: 974ms
memory: 150176kb

input:

201
-100
-99
-98
-97
-96
-95
-94
-93
-92
-91
-90
-89
-88
-87
-86
-85
-84
-83
-82
-81
-80
-79
-78
-77
-76
-75
-74
-73
-72
-71
-70
-69
-68
-67
-66
-65
-64
-63
-62
-61
-60
-59
-58
-57
-56
-55
-54
-53
-52
-51
-50
-49
-48
-47
-46
-45
-44
-43
-42
-41
-40
-39
-38
-37
-36
-35
-34
-33
-32
-31
-30
-29
-28
-27...

output:

202
202
199
197
194
193
191
194
194
194
194
181
178
178
178
173
178
178
166
166
163
166
158
157
158
158
151
149
146
146
142
142
139
137
134
134
131
134
127
134
122
122
118
118
118
113
118
109
106
106
103
101
106
97
94
94
94
89
86
86
82
82
79
82
74
73
71
74
67
74
62
61
58
58
58
53
58
58
46
46
43
41
3...

result:

wrong answer 8th numbers differ - expected: '191', found: '194'