# permutation 2

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)

Problem Description
You are given three positive integers

Input
The first line contains one integer

Output
For each test, output one integer in a single line indicating the answer modulo

Sample Input
3
4 1 4
4 2 4
100000 514 51144

Sample Output
2
1
253604680

 1 #include<bits/stdc++.h>
2 #define ll long long
3 using namespace std;
4 #define maxn 100005
5 #define mod 998244353
6 ll fac[maxn];
7 int main()
8 {
9     fac[0]=0;
10     fac[1]=1;
11     fac[2]=1;
12     for(int i=3; i<=maxn-2; i++)
13     {
14         fac[i]=(fac[i-1]+fac[i-3])%mod;
15     }
16     int t;
17     scanf("%d",&t);
18     while(t--)
19     {
20         int n,a,b;
21         scanf("%d%d%d",&n,&a,&b);
22         int ans=b-a;
23         if(a==1&&b==n)ans++;
24         else if(a!=1&&b!=n)ans--;
25         printf("%lld\n",fac[ans]);
26     }
27     return 0;
28 }
29 /*
30 3
31 4 1 4
32 4 2 4
33 100000 514 51144
34 */

2019HDU多校训练第五场1007-permutation 2

(0)
(0)