QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#351103#8329. Excuseucup-team1004TL 5ms8112kbC++141.7kb2024-03-11 15:42:342024-03-11 15:42:34

Judging History

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

  • [2024-03-11 15:42:34]
  • 评测
  • 测评结果:TL
  • 用时:5ms
  • 内存:8112kb
  • [2024-03-11 15:42:34]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e5+5,M=(1<<20)+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const ll INF=2e18+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n;ll frc[N],inv[N],f[N],g[N],pw[N],iw[N];
ll C(int x,int y){return frc[x]*inv[y]%mod*inv[x-y]%mod;}
void Solve(){
	int i,j;scanf("%d",&n);
	inv[1]=1;for(i=2;i<=n;i++) inv[i]=(mod-inv[mod%i])*(mod/i)%mod;
	for(frc[0]=inv[0]=i=1;i<=n;i++) frc[i]=frc[i-1]*i%mod,inv[i]=inv[i]*inv[i-1]%mod;
	for(pw[0]=iw[0]=i=1;i<=n;i++) pw[i]=pw[i-1]*2%mod,iw[i]=iw[i-1]*(mod+1)/2%mod;
	f[0]=0;g[0]=1;
	for(i=1;i<=n;i++){
		for(j=0;j<i;j++) f[i]=(f[i]+(f[j]+g[j])*C(n-j,n-i)%mod*iw[n-j])%mod,g[i]=(g[i]+g[j]*C(n-j,n-i)%mod*iw[n-j])%mod;
	}
	ll ans=0;for(i=0;i<=n;i++) ans+=f[i]*iw[n-i]%mod;
	printf("%lld",ans%mod);
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 8112kb

input:

1

output:

499122177

result:

ok 1 number(s): "499122177"

Test #2:

score: 0
Accepted
time: 1ms
memory: 6000kb

input:

3

output:

561512450

result:

ok 1 number(s): "561512450"

Test #3:

score: 0
Accepted
time: 1ms
memory: 8108kb

input:

10

output:

609769250

result:

ok 1 number(s): "609769250"

Test #4:

score: 0
Accepted
time: 5ms
memory: 8108kb

input:

1000

output:

475714976

result:

ok 1 number(s): "475714976"

Test #5:

score: 0
Accepted
time: 5ms
memory: 6104kb

input:

1024

output:

178624793

result:

ok 1 number(s): "178624793"

Test #6:

score: -100
Time Limit Exceeded

input:

100000

output:


result: