QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#328571#7881. Computational ComplexityCall_me_EricWA 59ms16804kbC++171.9kb2024-02-15 21:21:262024-04-09 19:11:12

Judging History

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

  • [2024-04-09 19:11:12]
  • 管理员手动重测该提交记录
  • 测评结果:WA
  • 用时:59ms
  • 内存:16804kb
  • [2024-02-15 21:21:26]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
bool stmemory;
namespace Call_me_Eric{
inline int read(){
    int x = 0, f = 1;char ch = getchar();
    while(ch < '0' || ch > '9'){if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = (x << 1) + (x << 3) + (ch ^ 48);ch = getchar();}
    return x * f;
}
const int maxn = 1e6 + 10, N = 1e15;
int f[maxn], g[maxn];
set<int> s;
int a[maxn], tot, T, mod;
inline int F(int x,int y){return a[x] % y ? 0 : f[lower_bound(a,a + 1 + tot,a[x] / y) - a];}
inline int G(int x,int y){return a[x] % y ? 0 : g[lower_bound(a,a + 1 + tot,a[x] / y) - a];}
void main(){
    f[0] = read(); g[0] = read(); T = read(); mod = read();
    f[0] %= mod;g[0] %= mod;
    for(int i = 1;i <= 13;i++){
        f[i] = max(i,g[i / 2] + g[i / 3] + g[i / 5] + g[i / 7]);
        g[i] = max(i,f[i / 2] + f[i / 3] + f[i / 5] + f[i / 4]);
    }
    for(int i = 13;i >= 1;i--){
        f[i] -= f[i - 1];g[i] -= g[i - 1];
        f[i] = (f[i] % mod + mod) % mod;
        g[i] = (g[i] % mod + mod) % mod;
    }
    for(int i = 1;i <= 13;i++)for(int j = i;j <= N;j *= 2)
    for(int k = j;k <= N;k *= 3)for(int l = k;l <= N;l *= 5)
    for(int p = l;p <= N;p *= 7)s.insert(p);
    for(int i : s)a[++tot] = i;
    for(int i = 14;i <= tot;i++){
        f[i] = (G(i,2) + G(i,3) + G(i,5) + G(i,7)) % mod;
        g[i] = (F(i,2) + F(i,3) + F(i,5) + F(i,4)) % mod;
    }
    for(int i = 1;i <= tot;i++){f[i] = (f[i] + f[i - 1]) % mod;g[i] = (g[i] + g[i - 1]) % mod;}
    while(T--){int pos = upper_bound(a,a + 1 + tot,read()) - a - 1;printf("%lld %lld\n",f[pos],g[pos]);}
    return;
}
};
bool edmemory;
signed main(){
    // freopen("tmp.in","r",stdin);
    auto stclock = clock();
    Call_me_Eric::main();
    auto edclock = clock();
    cerr << (&stmemory - &edmemory) / 1024.0 / 1024.0 << " Mib cost.\n";
    cerr << (edclock - stclock) * 1.0 / CLOCKS_PER_SEC << " Sec cost.\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 56ms
memory: 16804kb

input:

1958 920 10 100000000000
0
1
2
3
10
100
200
1000
19580920
20232023

output:

1958 920
3680 7832
10592 9554
17504 11276
50294 64826
784112 893714
1894550 1905470
12057866 12979424
71481494756 48626708512
28127864908 7251681354

result:

ok 20 numbers

Test #2:

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

input:

0 0 10 100000000000
0
1
2
3
4
10
20
30
40
100

output:

0 0
1 1
2 2
3 3
4 4
11 12
25 26
41 41
55 58
162 172

result:

ok 20 numbers

Test #3:

score: -100
Wrong Answer
time: 59ms
memory: 14732kb

input:

2023 2023 10 2023
0
1
2
3
4
5
6
7
8
9

output:

0 0
1 1
2 2
3 3
4 4
5 5
6 7
7 7
8 9
9 10

result:

wrong answer 3rd numbers differ - expected: '0', found: '1'