Submission #61382873
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ui = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,l,r) for(int i=(l);i>=(r);--i)
#define repn(i,n) for(int i=0;i<(n);++i)
#define sizc(x) ((int)(x).size())
#define allc(x) (x).begin(),(x).end()
#define fir first
#define sec second
constexpr int N = 3e5+5;
using Z = modint998244353;
int n;
Z fac[N],invf[N];
void init(int n){
fac[0]=1;
rep(i,1,n)fac[i]=fac[i-1]*i;
invf[n]=1/fac[n];
per(i,n,1)invf[i-1]=invf[i]*i;
}
bitset<N> vis;
void sieve(int n){
rep(i,2,n)if(!vis[i])rep(j,2,n/i)vis[i*j]=1;
}
Z g[N],f[N];
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n,init(n),sieve(n);
g[1]=n;
rep(i,3,n)if(!vis[i])g[i]=fac[i-1]/2*n*i;
f[0]=1;
auto dc=[&](auto &&self,int l,int r)->void{
if(l==r){if(l)f[l]*=fac[l-1];return;}
int mid=l+r>>1;
self(self,l,mid);
vector<Z> a(mid-l+1),b(r-l+1);
rep(i,l,mid)a[i-l]=f[i]*invf[i];
rep(i,1,r-l)b[i]=g[i]*invf[i-1];
vector<Z> res=convolution(a,b);
rep(i,mid+1,r)f[i]+=res[i-l];
self(self,mid+1,r);
};dc(dc,0,n);
cout<<(f[n]/n/n).val()<<'\n';
}
Submission Info
Submission Time |
|
Task |
G - Prime Circuit |
User |
KnownError_ |
Language |
C++ 20 (gcc 12.2) |
Score |
675 |
Code Size |
1450 Byte |
Status |
AC |
Exec Time |
274 ms |
Memory |
14992 KB |
Compile Error
Main.cpp: In instantiation of ‘main()::<lambda(auto:55&&, int, int)> [with auto:55 = main()::<lambda(auto:55&&, int, int)>&]’:
Main.cpp:59:9: required from here
Main.cpp:51:18: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
51 | int mid=l+r>>1;
| ~^~
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
675 / 675 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 01_small_08.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 03_max_00.txt, 03_max_01.txt, 03_max_02.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_00.txt |
AC |
13 ms |
8092 KB |
00_sample_01.txt |
AC |
4 ms |
8164 KB |
00_sample_02.txt |
AC |
63 ms |
9680 KB |
01_small_00.txt |
AC |
3 ms |
8172 KB |
01_small_01.txt |
AC |
3 ms |
8060 KB |
01_small_02.txt |
AC |
3 ms |
8192 KB |
01_small_03.txt |
AC |
3 ms |
8108 KB |
01_small_04.txt |
AC |
3 ms |
8192 KB |
01_small_05.txt |
AC |
3 ms |
8180 KB |
01_small_06.txt |
AC |
3 ms |
8164 KB |
01_small_07.txt |
AC |
3 ms |
8184 KB |
01_small_08.txt |
AC |
3 ms |
8152 KB |
02_random_00.txt |
AC |
56 ms |
9356 KB |
02_random_01.txt |
AC |
26 ms |
8636 KB |
02_random_02.txt |
AC |
264 ms |
14472 KB |
02_random_03.txt |
AC |
264 ms |
14528 KB |
02_random_04.txt |
AC |
121 ms |
11168 KB |
03_max_00.txt |
AC |
274 ms |
14992 KB |
03_max_01.txt |
AC |
274 ms |
14976 KB |
03_max_02.txt |
AC |
272 ms |
14976 KB |