QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#96235#2919. SubprimeAbdelrahman_K#AC ✓152ms40812kbC++141.8kb2023-04-13 17:36:342023-04-13 17:36:37

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-13 17:36:37]
  • 评测
  • 测评结果:AC
  • 用时:152ms
  • 内存:40812kb
  • [2023-04-13 17:36:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
const int N = 2e7 + 2;
bool sieve[N];
vector<ll> primes;

void pre() {
    sieve[0] = sieve[1] = 1;
    for (ll i = 2; i < N; i++) {
        if (sieve[i])
            continue;
        primes.push_back(i);
        for (ll j = i*i; j < N; j += i) {
            sieve[j] = 1;
        }
    }
}

int check(string p, string x) {
    for (int i = 0; i < x.size(); i++) {
        if (x.substr(i, p.size()) == p) {
            return 1;
        }
    }
    return 0;
}

int main() {
    pre();
    int l, h;
    cin >> l >> h;
    string p;
    cin >> p;
    int ans = 0;
    for (int i = l - 1; i <= h - 1; i++) {
        ans += check(p, to_string(primes[i]));
    }
    cout << ans;
//    int x, y;
//    cin >> x >> y;
//    if (x > y) swap(x, y);
//    string s;
//    cin >> s;
//    int a[4] = {};
//    for (int i = 0; i < 4; i++) {
//        if (s[i] == 'A') {
//            if (x)
//                a[i] = x, x = 0;
//            else
//                a[i] = y;
//        }
//    }
//    if (s[0] == 'B')
//        a[0] = 1;
//    if (s[3] == 'B')
//        a[3] = 9;
//    cout << a[3] << ' ' << a[2] << '\n';
//    if (s[1] == 'B' && s[2] == 'B' && a[3] - a[0] != 3) {
//        a[1] = a[2] = -1;
//    }
//    else {
//        if (s[1] == 'B' && a[2] - a[0] != 2)
//            a[1] = -1;
//        if (s[2] == 'B' && a[3] - a[1] != 2)
//            a[2] = -1;
//    }
//    sort(a,a + 4);
//    for (int i = 0; i < 4; i++) {
//        if ((i && a[i] - a[i - 1] != 1) || a[0] == -1)
//            return cout << -1, 0;
//    }
//    for (int i = 0; i < 4; i++) {
//        if (s[i] == 'B')
//            cout << a[i] << ' ';
//    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 131ms
memory: 39824kb

input:

1 10000
389

output:

45

result:

ok single line: '45'

Test #2:

score: 0
Accepted
time: 114ms
memory: 39564kb

input:

1 100
8

output:

8

result:

ok single line: '8'

Test #3:

score: 0
Accepted
time: 98ms
memory: 40256kb

input:

8000 9000
395

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 123ms
memory: 40316kb

input:

50000 80000
572

output:

63

result:

ok single line: '63'

Test #5:

score: 0
Accepted
time: 125ms
memory: 40328kb

input:

90000 100000
9999

output:

5

result:

ok single line: '5'

Test #6:

score: 0
Accepted
time: 116ms
memory: 38856kb

input:

1 100000
37502

output:

1

result:

ok single line: '1'

Test #7:

score: 0
Accepted
time: 110ms
memory: 38868kb

input:

1 1000
000

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 115ms
memory: 40384kb

input:

4509 12345
9999

output:

4

result:

ok single line: '4'

Test #9:

score: 0
Accepted
time: 121ms
memory: 40296kb

input:

1 1
2

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 122ms
memory: 39068kb

input:

2 8
2

output:

0

result:

ok single line: '0'

Test #11:

score: 0
Accepted
time: 126ms
memory: 39564kb

input:

2 9
2

output:

1

result:

ok single line: '1'

Test #12:

score: 0
Accepted
time: 126ms
memory: 39584kb

input:

1 100000
2

output:

44448

result:

ok single line: '44448'

Test #13:

score: 0
Accepted
time: 132ms
memory: 39792kb

input:

1 100000
0

output:

38298

result:

ok single line: '38298'

Test #14:

score: 0
Accepted
time: 128ms
memory: 39788kb

input:

1 100000
00

output:

3384

result:

ok single line: '3384'

Test #15:

score: 0
Accepted
time: 125ms
memory: 38912kb

input:

1 100000
000000

output:

0

result:

ok single line: '0'

Test #16:

score: 0
Accepted
time: 123ms
memory: 39628kb

input:

6 6
13

output:

1

result:

ok single line: '1'

Test #17:

score: 0
Accepted
time: 126ms
memory: 40388kb

input:

19 19
67

output:

1

result:

ok single line: '1'

Test #18:

score: 0
Accepted
time: 118ms
memory: 40596kb

input:

2137 2137
18719

output:

1

result:

ok single line: '1'

Test #19:

score: 0
Accepted
time: 118ms
memory: 39560kb

input:

1 100000
1

output:

65575

result:

ok single line: '65575'

Test #20:

score: 0
Accepted
time: 105ms
memory: 39352kb

input:

1 100000
9

output:

54268

result:

ok single line: '54268'

Test #21:

score: 0
Accepted
time: 146ms
memory: 40696kb

input:

12345 98765
0021

output:

40

result:

ok single line: '40'

Test #22:

score: 0
Accepted
time: 119ms
memory: 40236kb

input:

12345 98765
0201

output:

38

result:

ok single line: '38'

Test #23:

score: 0
Accepted
time: 140ms
memory: 40812kb

input:

12345 98765
2022

output:

21

result:

ok single line: '21'

Test #24:

score: 0
Accepted
time: 123ms
memory: 39684kb

input:

12345 98765
0222

output:

16

result:

ok single line: '16'

Test #25:

score: 0
Accepted
time: 127ms
memory: 39340kb

input:

1 100000
123456

output:

0

result:

ok single line: '0'

Test #26:

score: 0
Accepted
time: 132ms
memory: 40456kb

input:

1 100000
999937

output:

0

result:

ok single line: '0'

Test #27:

score: 0
Accepted
time: 138ms
memory: 39504kb

input:

1 100000
999953

output:

1

result:

ok single line: '1'

Test #28:

score: 0
Accepted
time: 129ms
memory: 38796kb

input:

1 100000
299709

output:

1

result:

ok single line: '1'

Test #29:

score: 0
Accepted
time: 116ms
memory: 40496kb

input:

1 99999
299709

output:

0

result:

ok single line: '0'

Test #30:

score: 0
Accepted
time: 119ms
memory: 40184kb

input:

50000 100000
611953

output:

1

result:

ok single line: '1'

Test #31:

score: 0
Accepted
time: 120ms
memory: 39132kb

input:

50001 100000
611953

output:

0

result:

ok single line: '0'

Test #32:

score: 0
Accepted
time: 121ms
memory: 39416kb

input:

1 100000
12345

output:

8

result:

ok single line: '8'

Test #33:

score: 0
Accepted
time: 118ms
memory: 39300kb

input:

1 100000
2053

output:

46

result:

ok single line: '46'

Test #34:

score: 0
Accepted
time: 137ms
memory: 39088kb

input:

3 5
3

output:

0

result:

ok single line: '0'

Test #35:

score: 0
Accepted
time: 108ms
memory: 39512kb

input:

2 6
3

output:

2

result:

ok single line: '2'

Test #36:

score: 0
Accepted
time: 120ms
memory: 39720kb

input:

1 669
4999

output:

1

result:

ok single line: '1'

Test #37:

score: 0
Accepted
time: 116ms
memory: 40280kb

input:

260 309
003

output:

1

result:

ok single line: '1'

Test #38:

score: 0
Accepted
time: 116ms
memory: 40744kb

input:

1110 1159
151

output:

1

result:

ok single line: '1'

Test #39:

score: 0
Accepted
time: 108ms
memory: 40204kb

input:

145 155
88

output:

3

result:

ok single line: '3'

Test #40:

score: 0
Accepted
time: 128ms
memory: 40200kb

input:

2 99999
0

output:

38297

result:

ok single line: '38297'

Test #41:

score: 0
Accepted
time: 117ms
memory: 39228kb

input:

1911 2000
111

output:

0

result:

ok single line: '0'

Test #42:

score: 0
Accepted
time: 122ms
memory: 38944kb

input:

99960 100000
9709

output:

1

result:

ok single line: '1'

Test #43:

score: 0
Accepted
time: 124ms
memory: 39608kb

input:

1 9
2

output:

2

result:

ok single line: '2'

Test #44:

score: 0
Accepted
time: 128ms
memory: 40064kb

input:

16498 80565
56756

output:

1

result:

ok single line: '1'

Test #45:

score: 0
Accepted
time: 121ms
memory: 40312kb

input:

15975 23849
69814

output:

0

result:

ok single line: '0'

Test #46:

score: 0
Accepted
time: 120ms
memory: 40396kb

input:

21354 64868
3299

output:

23

result:

ok single line: '23'

Test #47:

score: 0
Accepted
time: 124ms
memory: 38912kb

input:

1 100000
129

output:

1284

result:

ok single line: '1284'

Test #48:

score: 0
Accepted
time: 152ms
memory: 40444kb

input:

30521 89695
22212

output:

0

result:

ok single line: '0'

Test #49:

score: 0
Accepted
time: 132ms
memory: 40224kb

input:

1 1
99

output:

0

result:

ok single line: '0'

Test #50:

score: 0
Accepted
time: 120ms
memory: 38848kb

input:

1 9
99

output:

0

result:

ok single line: '0'

Test #51:

score: 0
Accepted
time: 119ms
memory: 38928kb

input:

1 10
9

output:

2

result:

ok single line: '2'

Test #52:

score: 0
Accepted
time: 137ms
memory: 40380kb

input:

500 1000
43

output:

26

result:

ok single line: '26'

Test #53:

score: 0
Accepted
time: 124ms
memory: 39468kb

input:

1 1000
00

output:

10

result:

ok single line: '10'