QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#726201#2919. Subprimezeyu#AC ✓68ms21296kbC++232.3kb2024-11-08 22:16:542024-11-08 22:16:55

Judging History

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

  • [2024-11-08 22:16:55]
  • 评测
  • 测评结果:AC
  • 用时:68ms
  • 内存:21296kb
  • [2024-11-08 22:16:54]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pl pair<ll, ll>
#define pi pair<int, int>
#define minpq priority_queue<ll, vector<ll>, greater<ll>>
using namespace std;

#if 1
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '['; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "]";}
void _print() {cerr << endl << flush;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "*["<<__LINE__<<"]\t"<< #x << " = "; _print(x)
#endif

const ll mod = 1e9 + 7;

template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll gcd(ll a, ll b) {if(b == 0){return a;} return gcd(b, a % b);}

const int maxn = 2000020;
int p[maxn];
vector<string> primes;

void sieve(){
	for (int i = 0; i < maxn; i ++) p[i] = i;
	for (int i = 2; i < maxn; i ++){
		for (int j = i + i; j < maxn; j += i){
			p[j] = i;
		}
	}
}

bool issubstr(string s, string t){
	if (t.size() > s.size()) return false;
	for (int i = 0; i <= s.size() - t.size(); i ++){
		if (s.substr(i, t.size()) == t) return true;
	}
	return false;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	sieve();
	for (int i = 2; i < maxn; i ++) if (p[i] == i) primes.push_back(to_string(i));
	int l, h; cin >> l >> h; l --; h --;
	string p; cin >> p;
	int ans = 0;
	for (int i = l; i <= h; i ++) if (issubstr(primes[i], p)) ans ++;
	cout << ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 60ms
memory: 19808kb

input:

1 10000
389

output:

45

result:

ok single line: '45'

Test #2:

score: 0
Accepted
time: 60ms
memory: 19804kb

input:

1 100
8

output:

8

result:

ok single line: '8'

Test #3:

score: 0
Accepted
time: 59ms
memory: 20568kb

input:

8000 9000
395

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 58ms
memory: 20844kb

input:

50000 80000
572

output:

63

result:

ok single line: '63'

Test #5:

score: 0
Accepted
time: 56ms
memory: 20256kb

input:

90000 100000
9999

output:

5

result:

ok single line: '5'

Test #6:

score: 0
Accepted
time: 61ms
memory: 19740kb

input:

1 100000
37502

output:

1

result:

ok single line: '1'

Test #7:

score: 0
Accepted
time: 53ms
memory: 20612kb

input:

1 1000
000

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 62ms
memory: 20840kb

input:

4509 12345
9999

output:

4

result:

ok single line: '4'

Test #9:

score: 0
Accepted
time: 63ms
memory: 19936kb

input:

1 1
2

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 59ms
memory: 19260kb

input:

2 8
2

output:

0

result:

ok single line: '0'

Test #11:

score: 0
Accepted
time: 59ms
memory: 20920kb

input:

2 9
2

output:

1

result:

ok single line: '1'

Test #12:

score: 0
Accepted
time: 61ms
memory: 19780kb

input:

1 100000
2

output:

44448

result:

ok single line: '44448'

Test #13:

score: 0
Accepted
time: 67ms
memory: 20988kb

input:

1 100000
0

output:

38298

result:

ok single line: '38298'

Test #14:

score: 0
Accepted
time: 68ms
memory: 19736kb

input:

1 100000
00

output:

3384

result:

ok single line: '3384'

Test #15:

score: 0
Accepted
time: 65ms
memory: 20376kb

input:

1 100000
000000

output:

0

result:

ok single line: '0'

Test #16:

score: 0
Accepted
time: 58ms
memory: 20476kb

input:

6 6
13

output:

1

result:

ok single line: '1'

Test #17:

score: 0
Accepted
time: 62ms
memory: 19652kb

input:

19 19
67

output:

1

result:

ok single line: '1'

Test #18:

score: 0
Accepted
time: 59ms
memory: 20356kb

input:

2137 2137
18719

output:

1

result:

ok single line: '1'

Test #19:

score: 0
Accepted
time: 64ms
memory: 20296kb

input:

1 100000
1

output:

65575

result:

ok single line: '65575'

Test #20:

score: 0
Accepted
time: 59ms
memory: 20200kb

input:

1 100000
9

output:

54268

result:

ok single line: '54268'

Test #21:

score: 0
Accepted
time: 63ms
memory: 20424kb

input:

12345 98765
0021

output:

40

result:

ok single line: '40'

Test #22:

score: 0
Accepted
time: 63ms
memory: 21172kb

input:

12345 98765
0201

output:

38

result:

ok single line: '38'

Test #23:

score: 0
Accepted
time: 63ms
memory: 19928kb

input:

12345 98765
2022

output:

21

result:

ok single line: '21'

Test #24:

score: 0
Accepted
time: 60ms
memory: 20568kb

input:

12345 98765
0222

output:

16

result:

ok single line: '16'

Test #25:

score: 0
Accepted
time: 61ms
memory: 19636kb

input:

1 100000
123456

output:

0

result:

ok single line: '0'

Test #26:

score: 0
Accepted
time: 56ms
memory: 20384kb

input:

1 100000
999937

output:

0

result:

ok single line: '0'

Test #27:

score: 0
Accepted
time: 66ms
memory: 19392kb

input:

1 100000
999953

output:

1

result:

ok single line: '1'

Test #28:

score: 0
Accepted
time: 57ms
memory: 19752kb

input:

1 100000
299709

output:

1

result:

ok single line: '1'

Test #29:

score: 0
Accepted
time: 64ms
memory: 19216kb

input:

1 99999
299709

output:

0

result:

ok single line: '0'

Test #30:

score: 0
Accepted
time: 65ms
memory: 19456kb

input:

50000 100000
611953

output:

1

result:

ok single line: '1'

Test #31:

score: 0
Accepted
time: 64ms
memory: 19300kb

input:

50001 100000
611953

output:

0

result:

ok single line: '0'

Test #32:

score: 0
Accepted
time: 62ms
memory: 20868kb

input:

1 100000
12345

output:

8

result:

ok single line: '8'

Test #33:

score: 0
Accepted
time: 60ms
memory: 21296kb

input:

1 100000
2053

output:

46

result:

ok single line: '46'

Test #34:

score: 0
Accepted
time: 60ms
memory: 20256kb

input:

3 5
3

output:

0

result:

ok single line: '0'

Test #35:

score: 0
Accepted
time: 59ms
memory: 20180kb

input:

2 6
3

output:

2

result:

ok single line: '2'

Test #36:

score: 0
Accepted
time: 64ms
memory: 19804kb

input:

1 669
4999

output:

1

result:

ok single line: '1'

Test #37:

score: 0
Accepted
time: 60ms
memory: 19300kb

input:

260 309
003

output:

1

result:

ok single line: '1'

Test #38:

score: 0
Accepted
time: 60ms
memory: 20984kb

input:

1110 1159
151

output:

1

result:

ok single line: '1'

Test #39:

score: 0
Accepted
time: 64ms
memory: 19960kb

input:

145 155
88

output:

3

result:

ok single line: '3'

Test #40:

score: 0
Accepted
time: 61ms
memory: 20376kb

input:

2 99999
0

output:

38297

result:

ok single line: '38297'

Test #41:

score: 0
Accepted
time: 59ms
memory: 19460kb

input:

1911 2000
111

output:

0

result:

ok single line: '0'

Test #42:

score: 0
Accepted
time: 64ms
memory: 20216kb

input:

99960 100000
9709

output:

1

result:

ok single line: '1'

Test #43:

score: 0
Accepted
time: 60ms
memory: 21020kb

input:

1 9
2

output:

2

result:

ok single line: '2'

Test #44:

score: 0
Accepted
time: 58ms
memory: 20804kb

input:

16498 80565
56756

output:

1

result:

ok single line: '1'

Test #45:

score: 0
Accepted
time: 51ms
memory: 20804kb

input:

15975 23849
69814

output:

0

result:

ok single line: '0'

Test #46:

score: 0
Accepted
time: 61ms
memory: 19720kb

input:

21354 64868
3299

output:

23

result:

ok single line: '23'

Test #47:

score: 0
Accepted
time: 60ms
memory: 19368kb

input:

1 100000
129

output:

1284

result:

ok single line: '1284'

Test #48:

score: 0
Accepted
time: 65ms
memory: 19752kb

input:

30521 89695
22212

output:

0

result:

ok single line: '0'

Test #49:

score: 0
Accepted
time: 64ms
memory: 19876kb

input:

1 1
99

output:

0

result:

ok single line: '0'

Test #50:

score: 0
Accepted
time: 60ms
memory: 20352kb

input:

1 9
99

output:

0

result:

ok single line: '0'

Test #51:

score: 0
Accepted
time: 60ms
memory: 20660kb

input:

1 10
9

output:

2

result:

ok single line: '2'

Test #52:

score: 0
Accepted
time: 63ms
memory: 19164kb

input:

500 1000
43

output:

26

result:

ok single line: '26'

Test #53:

score: 0
Accepted
time: 52ms
memory: 20836kb

input:

1 1000
00

output:

10

result:

ok single line: '10'