QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#368085 | #5099. 朝圣道 | zyc070419 | 0 | 48ms | 105512kb | C++14 | 1.2kb | 2024-03-26 20:01:09 | 2024-03-26 20:01:10 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#include "pilgrimage.h"
using namespace std;
int mod, inv, C[5005][5005], ans;
map<ll, int> mp;
inline int read() {
char ch = getchar(); int x = 0;
while (!isdigit(ch)) {ch = getchar();}
while (isdigit(ch)) {x = x * 10 + ch - 48; ch = getchar();}
return x;
}
inline int add(int x, int y) {x += y; return x >= mod ? x - mod : x;}
inline int del(int x, int y) {x -= y; return x < 0 ? x + mod : x;}
inline void Add(int &x, int y) {x = add(x, y);}
inline void Del(int &x, int y) {x = del(x, y);}
inline int qpow(int x, int y) {
int res = 1;
while (y) {
if (y & 1) res = 1ll * res * x % mod;
x = 1ll * x * x % mod;
y >>= 1;
}
return res;
}
void init(int o, int p) {
mod = p;
inv = (mod + 1) / 2;
for (int i = 0; i <= 5000; ++i) {
C[i][0] = C[i][i] = 1;
for (int j = 1; j < i; ++j) C[i][j] = add(C[i - 1][j - 1], C[i - 1][j]);
}
}
int ask(ll n) {
if (mp.count(n)) return mp[n];
ans = 0;
for (int i = 0; i <= (n - 1) / 2; ++i) Add(ans, 1ll * C[2 * i][i] * del(1ll * (n + 1) * C[n][2 * i + 1] % mod, C[n + 1][2 * i + 2]) % mod * qpow(inv, 2 * i + 1) % mod);
ans = 1ll * ans * qpow(inv, n) % mod;
return mp[n] = ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 48ms
memory: 105512kb
input:
1 910276 554767 6 10 7 4 10 12 9 3 3 5 7 10 5 6 1 6 3 9 6 8 12 11 8 2 12 5 9 3 8 2 12 11 2 3 4 9 2 5 5 11 6 4 8 11 3 9 2 2 8 9 2 8 9 6 2 9 2 10 10 7 5 6 4 4 11 12 8 8 2 2 4 3 3 5 6 6 8 11 6 9 9 3 4 1 2 2 6 9 9 2 3 2 12 6 1 7 2 4 12 11 4 7 6 3 9 4 6 5 3 3 12 6 2 1 1 7 2 6 5 9 11 6 3 4 11 1 2 4 5 4 10...
output:
280093 459521 534587 164697 459521 114831 26560 537431 537431 254630 534587 459521 254630 280093 138692 280093 537431 26560 280093 57631 114831 399282 57631 208038 114831 254630 26560 537431 57631 208038 114831 399282 208038 537431 164697 26560 208038 254630 254630 399282 280093 164697 57631 399282 ...
result:
wrong answer 1st numbers differ - expected: '5419', found: '280093'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Runtime Error
Test #5:
score: 0
Runtime Error
input:
3 1 334547 8234
output:
Unauthorized output
result:
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Runtime Error
Test #8:
score: 0
Runtime Error
input:
6 958477 522361 280121915553826833 734266539148641647 72849162479700582 274266741463686096 60278972064195458 828423669427600612 571432949203039978 518511460268700898 486268614705621285 19216283231217074 611458416727512530 175147354285288662 799769622289998997 400123443628688299 145546980862133838 40...
output:
Unauthorized output
result:
Subtask #7:
score: 0
Skipped
Dependency #3:
0%
Subtask #8:
score: 0
Runtime Error
Test #33:
score: 0
Runtime Error
input:
8 9963 251 831797004675585320 494759973681332858 701341496127272302 252910460485222469 250965009655458584 366193481309061299 633134388675839346 791999098066205672 196620805863610860 363773642045280947 466508590762410710 407790578717064135 181590911404670570 570642047249889864 70138464625729452 23634...
output:
Unauthorized output
result:
Subtask #9:
score: 0
Skipped
Dependency #1:
0%