QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#270868#2919. SubprimePetroTarnavskyi#WA 21ms17656kbC++201.1kb2023-12-01 16:53:492023-12-01 16:53:50

Judging History

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

  • [2023-12-01 16:53:50]
  • 评测
  • 测评结果:WA
  • 用时:21ms
  • 内存:17656kb
  • [2023-12-01 16:53:49]
  • 提交

answer

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); i--)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;


const int N = 3 << 19;
int isP[N];


int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0);
	cout << fixed << setprecision(15);

	int l, r;
	cin >> l >> r;
	string p;
	cin >> p;
	
	string zeros = "";
	FOR(i, 0, SZ(p) - 1)
		zeros += "0";

	
	fill(isP, isP + N, 1);
	isP[0] = isP[1] = 0;
	vector<string> primes;
	primes.reserve(1e5);
	FOR(pr, 2, N)
	{
		if(!isP[pr])
			continue;
		for(int j = 2 * pr; j < N; j += pr)
			isP[j] = 0;
		primes.PB(zeros + to_string(pr));
	}
	
	int ans = 0;
	FOR(i, l - 1, r)
	{
		bool ok = 0;
		FOR(j, 0, SZ(primes[i]) - SZ(p) + 1)
		{
			if(primes[i].substr(j, SZ(p)) == p)
			{
				ok = 1;
				break;
			}
		}
		if(ok)
			ans++;
	}
	cout << ans << "\n";
	
	
	



	
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 12ms
memory: 16716kb

input:

1 10000
389

output:

45

result:

ok single line: '45'

Test #2:

score: 0
Accepted
time: 15ms
memory: 16056kb

input:

1 100
8

output:

8

result:

ok single line: '8'

Test #3:

score: 0
Accepted
time: 17ms
memory: 16756kb

input:

8000 9000
395

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 17ms
memory: 17460kb

input:

50000 80000
572

output:

63

result:

ok single line: '63'

Test #5:

score: 0
Accepted
time: 12ms
memory: 15844kb

input:

90000 100000
9999

output:

5

result:

ok single line: '5'

Test #6:

score: 0
Accepted
time: 12ms
memory: 16724kb

input:

1 100000
37502

output:

1

result:

ok single line: '1'

Test #7:

score: 0
Accepted
time: 9ms
memory: 17048kb

input:

1 1000
000

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 13ms
memory: 16388kb

input:

4509 12345
9999

output:

4

result:

ok single line: '4'

Test #9:

score: 0
Accepted
time: 7ms
memory: 16708kb

input:

1 1
2

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 11ms
memory: 17400kb

input:

2 8
2

output:

0

result:

ok single line: '0'

Test #11:

score: 0
Accepted
time: 15ms
memory: 17388kb

input:

2 9
2

output:

1

result:

ok single line: '1'

Test #12:

score: 0
Accepted
time: 13ms
memory: 16712kb

input:

1 100000
2

output:

44448

result:

ok single line: '44448'

Test #13:

score: 0
Accepted
time: 12ms
memory: 17516kb

input:

1 100000
0

output:

38298

result:

ok single line: '38298'

Test #14:

score: 0
Accepted
time: 20ms
memory: 17656kb

input:

1 100000
00

output:

3384

result:

ok single line: '3384'

Test #15:

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

input:

1 100000
000000

output:

0

result:

ok single line: '0'

Test #16:

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

input:

6 6
13

output:

1

result:

ok single line: '1'

Test #17:

score: 0
Accepted
time: 16ms
memory: 17328kb

input:

19 19
67

output:

1

result:

ok single line: '1'

Test #18:

score: 0
Accepted
time: 16ms
memory: 16404kb

input:

2137 2137
18719

output:

1

result:

ok single line: '1'

Test #19:

score: 0
Accepted
time: 17ms
memory: 17076kb

input:

1 100000
1

output:

65575

result:

ok single line: '65575'

Test #20:

score: 0
Accepted
time: 14ms
memory: 15868kb

input:

1 100000
9

output:

54268

result:

ok single line: '54268'

Test #21:

score: -100
Wrong Answer
time: 16ms
memory: 17508kb

input:

12345 98765
0021

output:

851

result:

wrong answer 1st lines differ - expected: '40', found: '851'