QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#57750 | #2919. Subprime | wtcherr# | AC ✓ | 28ms | 19512kb | C++20 | 2.8kb | 2022-10-22 19:43:10 | 2022-10-22 19:43:13 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define IO ios_base::sync_with_stdio(0), cin.tie(0)
const int mod = 1e9 + 7;
template <typename T>
void readArray(vector<T> &A)
{
for (T &i : A)
cin >> i;
}
template <typename T>
void readArray(vector<vector<T>> &A)
{
for (vector<T> &i : A)
readArray(i);
}
template <typename T>
void printArray(vector<T> A)
{
for (T i : A)
cout << i << " ";
cout << endl;
}
ll fastPow(ll a, ll b, ll m = mod)
{
a %= m;
ll res = 1;
while (b > 0)
{
if (b & 1)
res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}
bool isPrime(ll n, int iter = 5)
{
if (n < 4)
return n == 2 || n == 3;
for (int i = 0; i < iter; i++)
{
int a = 2 + rand() % (n - 3);
if (fastPow(a, n - 1, n) != 1)
return false;
}
return true;
}
ll inv(ll n, ll m = mod)
{
return fastPow(n, m - 2);
}
ll mul(ll a, ll b, ll m = mod)
{
return (a * b) % m;
}
ll add(ll a, ll b, ll m = mod)
{
return (a + b + m) % m;
}
void solve()
{
int l, h;
string p;
cin >> l >> h >> p;
vector<string> primes;
int mxn = 2e6;
vector<int> sp(mxn, -1);
for (int i = 2; i < mxn; i++)
{
if (sp[i] == -1)
{
primes.push_back(to_string(i));
for (int j = 1; j * i <= mxn; j++)
{
if (sp[j * i] == -1)
sp[j * i] = i;
}
}
}
int cnt = 0;
for (int z = l - 1; z < h; z++)
{
string i = primes[z];
for (int j = 0; j <= (int)i.length() - (int)p.length(); j++)
{
bool ok = true;
for (int k = 0; k < (int)p.length(); k++)
{
if (i[j + k] != p[k])
{
ok = false;
break;
}
}
if (ok)
{
cnt++;
// cout << z << " " << i << "\n";
break;
}
}
}
cout << cnt;
}
void trials()
{
int t, tt;
for (cin >> t, tt = t; t--; cout << endl)
{
// cout << "Case #" << tt - t << ": ";
solve();
}
}
int main()
{
// freopen("","r",stdin);
IO;
solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 25ms
memory: 19400kb
input:
1 10000 389
output:
45
result:
ok single line: '45'
Test #2:
score: 0
Accepted
time: 17ms
memory: 19484kb
input:
1 100 8
output:
8
result:
ok single line: '8'
Test #3:
score: 0
Accepted
time: 15ms
memory: 19464kb
input:
8000 9000 395
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 16ms
memory: 19400kb
input:
50000 80000 572
output:
63
result:
ok single line: '63'
Test #5:
score: 0
Accepted
time: 24ms
memory: 19452kb
input:
90000 100000 9999
output:
5
result:
ok single line: '5'
Test #6:
score: 0
Accepted
time: 23ms
memory: 19400kb
input:
1 100000 37502
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 17ms
memory: 19496kb
input:
1 1000 000
output:
0
result:
ok single line: '0'
Test #8:
score: 0
Accepted
time: 24ms
memory: 19396kb
input:
4509 12345 9999
output:
4
result:
ok single line: '4'
Test #9:
score: 0
Accepted
time: 28ms
memory: 19488kb
input:
1 1 2
output:
1
result:
ok single line: '1'
Test #10:
score: 0
Accepted
time: 19ms
memory: 19472kb
input:
2 8 2
output:
0
result:
ok single line: '0'
Test #11:
score: 0
Accepted
time: 20ms
memory: 19484kb
input:
2 9 2
output:
1
result:
ok single line: '1'
Test #12:
score: 0
Accepted
time: 27ms
memory: 19452kb
input:
1 100000 2
output:
44448
result:
ok single line: '44448'
Test #13:
score: 0
Accepted
time: 24ms
memory: 19468kb
input:
1 100000 0
output:
38298
result:
ok single line: '38298'
Test #14:
score: 0
Accepted
time: 24ms
memory: 19392kb
input:
1 100000 00
output:
3384
result:
ok single line: '3384'
Test #15:
score: 0
Accepted
time: 20ms
memory: 19388kb
input:
1 100000 000000
output:
0
result:
ok single line: '0'
Test #16:
score: 0
Accepted
time: 20ms
memory: 19304kb
input:
6 6 13
output:
1
result:
ok single line: '1'
Test #17:
score: 0
Accepted
time: 19ms
memory: 19512kb
input:
19 19 67
output:
1
result:
ok single line: '1'
Test #18:
score: 0
Accepted
time: 19ms
memory: 19476kb
input:
2137 2137 18719
output:
1
result:
ok single line: '1'
Test #19:
score: 0
Accepted
time: 18ms
memory: 19328kb
input:
1 100000 1
output:
65575
result:
ok single line: '65575'
Test #20:
score: 0
Accepted
time: 24ms
memory: 19464kb
input:
1 100000 9
output:
54268
result:
ok single line: '54268'
Test #21:
score: 0
Accepted
time: 22ms
memory: 19328kb
input:
12345 98765 0021
output:
40
result:
ok single line: '40'
Test #22:
score: 0
Accepted
time: 24ms
memory: 19400kb
input:
12345 98765 0201
output:
38
result:
ok single line: '38'
Test #23:
score: 0
Accepted
time: 14ms
memory: 19480kb
input:
12345 98765 2022
output:
21
result:
ok single line: '21'
Test #24:
score: 0
Accepted
time: 28ms
memory: 19404kb
input:
12345 98765 0222
output:
16
result:
ok single line: '16'
Test #25:
score: 0
Accepted
time: 17ms
memory: 19468kb
input:
1 100000 123456
output:
0
result:
ok single line: '0'
Test #26:
score: 0
Accepted
time: 21ms
memory: 19400kb
input:
1 100000 999937
output:
0
result:
ok single line: '0'
Test #27:
score: 0
Accepted
time: 23ms
memory: 19508kb
input:
1 100000 999953
output:
1
result:
ok single line: '1'
Test #28:
score: 0
Accepted
time: 21ms
memory: 19400kb
input:
1 100000 299709
output:
1
result:
ok single line: '1'
Test #29:
score: 0
Accepted
time: 21ms
memory: 19468kb
input:
1 99999 299709
output:
0
result:
ok single line: '0'
Test #30:
score: 0
Accepted
time: 25ms
memory: 19452kb
input:
50000 100000 611953
output:
1
result:
ok single line: '1'
Test #31:
score: 0
Accepted
time: 17ms
memory: 19404kb
input:
50001 100000 611953
output:
0
result:
ok single line: '0'
Test #32:
score: 0
Accepted
time: 20ms
memory: 19404kb
input:
1 100000 12345
output:
8
result:
ok single line: '8'
Test #33:
score: 0
Accepted
time: 24ms
memory: 19324kb
input:
1 100000 2053
output:
46
result:
ok single line: '46'
Test #34:
score: 0
Accepted
time: 16ms
memory: 19456kb
input:
3 5 3
output:
0
result:
ok single line: '0'
Test #35:
score: 0
Accepted
time: 20ms
memory: 19484kb
input:
2 6 3
output:
2
result:
ok single line: '2'
Test #36:
score: 0
Accepted
time: 20ms
memory: 19404kb
input:
1 669 4999
output:
1
result:
ok single line: '1'
Test #37:
score: 0
Accepted
time: 27ms
memory: 19388kb
input:
260 309 003
output:
1
result:
ok single line: '1'
Test #38:
score: 0
Accepted
time: 21ms
memory: 19400kb
input:
1110 1159 151
output:
1
result:
ok single line: '1'
Test #39:
score: 0
Accepted
time: 17ms
memory: 19464kb
input:
145 155 88
output:
3
result:
ok single line: '3'
Test #40:
score: 0
Accepted
time: 18ms
memory: 19420kb
input:
2 99999 0
output:
38297
result:
ok single line: '38297'
Test #41:
score: 0
Accepted
time: 23ms
memory: 19512kb
input:
1911 2000 111
output:
0
result:
ok single line: '0'
Test #42:
score: 0
Accepted
time: 11ms
memory: 19456kb
input:
99960 100000 9709
output:
1
result:
ok single line: '1'
Test #43:
score: 0
Accepted
time: 19ms
memory: 19464kb
input:
1 9 2
output:
2
result:
ok single line: '2'
Test #44:
score: 0
Accepted
time: 19ms
memory: 19420kb
input:
16498 80565 56756
output:
1
result:
ok single line: '1'
Test #45:
score: 0
Accepted
time: 19ms
memory: 19388kb
input:
15975 23849 69814
output:
0
result:
ok single line: '0'
Test #46:
score: 0
Accepted
time: 11ms
memory: 19316kb
input:
21354 64868 3299
output:
23
result:
ok single line: '23'
Test #47:
score: 0
Accepted
time: 27ms
memory: 19400kb
input:
1 100000 129
output:
1284
result:
ok single line: '1284'
Test #48:
score: 0
Accepted
time: 25ms
memory: 19472kb
input:
30521 89695 22212
output:
0
result:
ok single line: '0'
Test #49:
score: 0
Accepted
time: 9ms
memory: 19484kb
input:
1 1 99
output:
0
result:
ok single line: '0'
Test #50:
score: 0
Accepted
time: 23ms
memory: 19396kb
input:
1 9 99
output:
0
result:
ok single line: '0'
Test #51:
score: 0
Accepted
time: 26ms
memory: 19304kb
input:
1 10 9
output:
2
result:
ok single line: '2'
Test #52:
score: 0
Accepted
time: 24ms
memory: 19452kb
input:
500 1000 43
output:
26
result:
ok single line: '26'
Test #53:
score: 0
Accepted
time: 18ms
memory: 19416kb
input:
1 1000 00
output:
10
result:
ok single line: '10'