QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#618189#9270. Deep Primesartinz#AC ✓0ms3760kbC++171.4kb2024-10-06 19:38:442024-10-06 19:38:47

Judging History

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

  • [2024-10-06 19:38:47]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3760kb
  • [2024-10-06 19:38:44]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using lli = int64_t;
using pii = pair<int, int>;
using vint = vector<int>;
using triple = pair<int, pii>;
using C = int;
using P = complex<C>;

const int MX = 505;
const int MOD = 1e9 + 7;

lli n, m;
lli res = 0;

bool is_prime(lli x) {
    if (x % 2 == 0 && x != 2)
        return false;

    for (lli i = 3; i <= sqrt(x + 1); i += 2) {
        if (x % i == 0)
            return false;
    }

    return true;
}

lli Pow(lli b, lli p) {
    if (p == 0)
        return 1;

    lli a = Pow(b, p / 2);

    if (p % 2 == 1) {
        return a * a * b;
    }

    return a * a;
}

void solution(lli x, lli d = 1) {
    if (x > m)
        return;

    if (!is_prime(x))
        return;

    if (x >= n) {
        res++;
    }

    lli ld = x / Pow(10, d - 1);

    if (ld == 2 || ld == 5)
        return;

    if (ld == 3) {
        solution(7 * Pow(10, d) + x, d + 1);
    } else {
        solution(3 * Pow(10, d) + x, d + 1);
    }

    solution(2 * Pow(10, d) + x, d + 1);
    solution(5 * Pow(10, d) + x, d + 1);
}

void solve() {
    cin >> n >> m;

    solution(2);
    solution(3);
    solution(5);
    solution(7);

    cout << res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    // cin >> t;

    while (t--) {
        solve();
        cout << '\n';
    }

    return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3508kb

input:

1 11

output:

4

result:

ok answer is '4'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

1 1

output:

0

result:

ok answer is '0'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

1 1000000000000000000

output:

9

result:

ok answer is '9'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

1000000000000000000 1000000000000000000

output:

0

result:

ok answer is '0'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

736 738

output:

0

result:

ok answer is '0'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

5373 5374

output:

0

result:

ok answer is '0'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

1 3

output:

2

result:

ok answer is '2'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

2 9

output:

4

result:

ok answer is '4'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

2 4

output:

2

result:

ok answer is '2'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

3 373

output:

8

result:

ok answer is '8'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

4 6

output:

1

result:

ok answer is '1'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

5 55

output:

5

result:

ok answer is '5'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

6 8

output:

1

result:

ok answer is '1'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

7 39

output:

3

result:

ok answer is '3'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

22 24

output:

1

result:

ok answer is '1'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

23 40

output:

2

result:

ok answer is '2'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

36 38

output:

1

result:

ok answer is '1'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3492kb

input:

37 53

output:

2

result:

ok answer is '2'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

52 54

output:

1

result:

ok answer is '1'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

53 378

output:

3

result:

ok answer is '3'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

72 74

output:

1

result:

ok answer is '1'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

73 374

output:

2

result:

ok answer is '2'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3704kb

input:

372 374

output:

1

result:

ok answer is '1'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

645762258982631932 885295149831742591

output:

0

result:

ok answer is '0'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

819875141880895728 946247261349950347

output:

0

result:

ok answer is '0'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

891351282707723857 891429887621456547

output:

0

result:

ok answer is '0'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

520974001910286918 960365366546346049

output:

0

result:

ok answer is '0'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

856674611404539679 912190643721143050

output:

0

result:

ok answer is '0'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

711066337317063340 908820864712129941

output:

0

result:

ok answer is '0'

Test #30:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

234122432773361868 906278314445745617

output:

0

result:

ok answer is '0'

Test #31:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

999594448650287940 999671970710526657

output:

0

result:

ok answer is '0'

Test #32:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

676105575462224593 841790036199317881

output:

0

result:

ok answer is '0'

Test #33:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

752304352384836991 848405248582489040

output:

0

result:

ok answer is '0'

Test #34:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

291499943576823355 462093425359000422

output:

0

result:

ok answer is '0'

Test #35:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

192583020404011431 945814124262134310

output:

0

result:

ok answer is '0'

Test #36:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

363434583954291757 947385169886199754

output:

0

result:

ok answer is '0'

Test #37:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

594688604155374934 649541852103467921

output:

0

result:

ok answer is '0'

Test #38:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

662180230164163676 899422968245266530

output:

0

result:

ok answer is '0'

Test #39:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

543390476138996221 576565748335876400

output:

0

result:

ok answer is '0'

Test #40:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

746055710353195922 859032117962645886

output:

0

result:

ok answer is '0'

Test #41:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

935387048910748511 999143227013178277

output:

0

result:

ok answer is '0'

Test #42:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

617116466913575467 892257825396149858

output:

0

result:

ok answer is '0'

Extra Test:

score: 0
Extra Test Passed