QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#545885 | #7927. Fortune Telling | AA_Surely# | WA | 5ms | 20220kb | C++23 | 1.6kb | 2024-09-03 17:56:24 | 2024-09-03 17:56:24 |
Judging History
answer
#pragma GCC optimize("O3,unroll-loops,no-stack-protector")
//#pragma GCC target("avx,avx2,bmi,bmi2")
#include <bits/stdc++.h>
#define FOR(i, x, n) for(int i = x; i < n; i++)
#define F0R(i, n) FOR(i, 0, n)
#define ROF(i, x, n) for(int i = n - 1; i >= x; i--)
#define R0F(i, n) ROF(i, 0, n)
#define WTF cout << "WTF" << endl
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define PB push_back
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef complex<LD> Point;
const int N = 3e5 + 7;
const int INF = 1e9 + 7;
const int LOG = 22;
const int A = 26;
const int SQ = 320;
const int MOD = 998'244'353;
LL in[7];
LL pw(LL a, LL b) {
LL ret = 1;
while(b) {
if (b & 1) ret = ret * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return ret;
}
LL inv(LL x) {
return pw(x, MOD - 2);
}
unordered_map<int, LL> dp[N];
LL get(int n, int r) {
if (n == 0) return 1;
r = min(r, n - r);
if (dp[n][r] || dp[n][n - r]) return max(dp[n][r], dp[n][n - r]);
LL ret = 0;
F0R(i, min(6, n + 1)) if (r % 6 != i)
ret = (ret + in[min(6, n + 1)] * get(n - (n / 6) - (n % 6 >= i), r - (r / 6) - (r % 6 >= i)) % MOD) % MOD;
return dp[n][r] = ret;
}
int main() {
IOS;
int n;
F0R(i, 7) in[i] = inv(i);
cin >> n;
//F0R(i, n) cout << get(n - 1, i) << '\n';
F0R(i, n) get(n - 1, i);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 20220kb
input:
3
output:
result:
wrong answer 1st lines differ - expected: '332748118', found: ''