D. Radio Towers

194 篇文章 1 订阅
2 篇文章 0 订阅

https://codeforces.ml/contest/1452/problem/D

There are n+2n+2 towns located on a coordinate line, numbered from 00 to n+1n+1. The ii-th town is located at the point ii.

You build a radio tower in each of the towns 1,2,…,n1,2,…,n with probability 1212 (these events are independent). After that, you want to set the signal power on each tower to some integer from 11 to nn (signal powers are not necessarily the same, but also not necessarily different). The signal from a tower located in a town ii with signal power pp reaches every city cc such that |c−i|<p|c−i|<p.

After building the towers, you want to choose signal powers in such a way that:

  • towns 00 and n+1n+1 don't get any signal from the radio towers;
  • towns 1,2,…,n1,2,…,n get signal from exactly one radio tower each.

For example, if n=5n=5, and you have built the towers in towns 22, 44 and 55, you may set the signal power of the tower in town 22 to 22, and the signal power of the towers in towns 44 and 55 to 11. That way, towns 00 and n+1n+1 don't get the signal from any tower, towns 11, 22 and 33 get the signal from the tower in town 22, town 44 gets the signal from the tower in town 44, and town 55 gets the signal from the tower in town 55.

Calculate the probability that, after building the towers, you will have a way to set signal powers to meet all constraints.

Input

The first (and only) line of the input contains one integer nn (1≤n≤2⋅1051≤n≤2⋅105).

Output

Print one integer — the probability that there will be a way to set signal powers so that all constraints are met, taken modulo 998244353998244353.

Formally, the probability can be expressed as an irreducible fraction xyxy. You have to print the value of x⋅y−1mod998244353x⋅y−1mod998244353, where y−1y−1 is an integer such that y⋅y−1mod998244353=1y⋅y−1mod998244353=1.

Examples

input

Copy

2

output

Copy

748683265

input

Copy

3

output

Copy

748683265

input

Copy

5

output

Copy

842268673

input

Copy

200000

output

Copy

202370013

Note

The real answer for the first example is 1414:

  • with probability 1414, the towers are built in both towns 11 and 22, so we can set their signal powers to 11.

The real answer for the second example is 1414:

  • with probability 1818, the towers are built in towns 11, 22 and 33, so we can set their signal powers to 11;
  • with probability 1818, only one tower in town 22 is built, and we can set its signal power to 22.

The real answer for the third example is 532532. Note that even though the previous explanations used equal signal powers for all towers, it is not necessarily so. For example, if n=5n=5 and the towers are built in towns 22, 44 and 55, you may set the signal power of the tower in town 22 to 22, and the signal power of the towers in towns 44 and 55 to 11.

 

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e6+5;
const ll mod=998244353;
ll n,t,k,s,y;
ll a[maxn];
ll poww(ll a,ll b)
{
    ll ans=1,base=a;
    while(b)
    {
        if(b&1)
        {
            ans*=base;
            ans%=mod;
        }
        base*=base;
        base%=mod;
        b>>=1;
    }
    return ans;
}
int main()
{
    cin>>n;
    ll p=poww(2,n);
    ll x=1,y=1;
    for(int i=2;i<=n;i++)
    {
        ll u=x+y;
        u%=mod;
        x=y;
        y=u;
    }
    ll ans=x*poww(p,mod-2);
    ans%=mod;
    cout<<ans<<endl;
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值