Educational Codeforces Round 98 (Rated for Div. 2) D. Radio Towers 组合数学

D. Radio Towers

在这里插入图片描述

input

200000

output

202370013

code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const int INF = 0x3f3f3f3f;
const int N = 3e5+10;
const int MOD = 998244353;
//
int n, m, f[N];
ll temp;
//
ll quick_pow(ll ans, ll p, ll res = 1) {
    
    
	for(; p; p >>= 1, ans = ans * ans % MOD)
		if(p & 1) res = res * ans % MOD;
	return res % MOD;
}
ll inv(ll ans) {
    
    
	return quick_pow(ans, MOD - 2) % MOD;
}
ll C(int n, int m) {
    
    
	return 1ll * f[n] * inv(f[n - m]) % MOD * inv(f[m]) % MOD;
}
inline void solve(ll res = 0, ll ans = 0) {
    
    
	ans = f[n];
	res = ans * inv(quick_pow(2, n)) % MOD;
	cout << res << endl;
}
int main() {
    
    
	f[0] = f[1] = f[2] = 1;
	for(int i = 3; i < N; ++ i)
		f[i] = (f[i - 1] + f[i - 2]) % MOD;
	cin >> n;
	solve();
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_46173805/article/details/114269379