2019杭电多校 permutation2
Problem:http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1007&cid=852
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll d[100005]; void f() { d[1]=d[2]=d[3]=1; for(int i=4;i<=100001;i++) d[i]=(d[i-1]+d[i-3])%998244353; } int main() { f();int t;scanf("%d",&t); while(t--) { ll n,x,y; scanf("%lld%lld%lld",&n,&x,&y); if(x==1&&y==n) printf("%d\n",d[n]); else if(x==1) printf("%d\n",d[y-1]); else if(y==n) printf("%d\n",d[n-x]); else printf("%d\n",d[y-x-1]); } return 0; }