QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#164055#6736. Alice and Bobyujie3TL 0ms0kbC++144.1kb2023-09-04 19:12:062023-09-04 19:12:06

Judging History

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

  • [2023-09-04 19:12:06]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-09-04 19:12:06]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define F first
#define S second
#define lowbit(x) ((x) & (-x))
#define _ int _T; cin >> _T; while(_T --) 
//#define int long long
#define no cout << "NO" << endl
#define yes cout << "YES" << endl

using namespace std;
typedef pair<int, int> PII;
typedef pair<char,int> PCI;
typedef long long ll;
const int N = 1e7 + 5;
const int MOD = 1e9 + 7;
const ll mod = 998244353;

int n,m,k;
//int a[N];
//int tree[N];
//int b[N],c[N];
//PII p[N];
//PCI pc[N];
string s;

ll fac[N];        //阶乘
ll inv[N];        //逆元 

ll quickMod(ll a,ll b)
{
	ll ans = 1;
	while (b)
	{
	    if (b&1)
	        ans = ans * a % mod;
	     a = a*a % mod;
	     b >>= 1;
	}
	return ans;
}
void getFac()
{
	fac[0] = inv[0] = 1;
	for (int i = 1 ; i <= N ; i++)
	{
	     fac[i] = fac[i-1] * i % mod;
	     inv[i] = quickMod(fac[i],mod-2);        //表示i的阶乘的逆元 
	}
}
ll getC(ll n,ll m)        //C(n,m) = n!/((n-m)!*m!) % (1e9+7)
{
	return fac[n] * inv[n-m] % mod;
}


//int fact[N];
//int inv[N];
//
//int qpow(int a,int b,int p)
//{
//    int res = 1;
//    while (b)
//    {
//        if (b & 1)
//            res = (res * a) % p;
//        a = (a * a) % p;
//        b /= 2;
//    }
//    return res % p;
//}
//
//void init()
//{
//    fact[0] = 1;
//    for (int i = 1; i <= N; i++)
//        fact[i] = (fact[i - 1] * i) % mod;
//    inv[N] = qpow(fact[N], mod - 2, mod);
//    for (int i = N - 1; i >= 0; i--)
//        inv[i] = (inv[i + 1] * (i + 1)) % mod;
//}
//
//int _get(int u,int d)
//{
//	if(u == 0) return 1;
//	int ans = d; u --;
//	for(int i = d - 1;u > 0;u --,i --)
//	ans *= i,ans %= mod;
//	return ans;
//}

void solve()
{
//	cin >> n;
//	for(int i = 1;i <= n;i ++)
//	a[i] = i;
//	do
//	{
//		for(int i = 1;i <= n;i ++)
//		cout << a[i] << " ";
//		cout << endl;
//	}while(next_permutation(a + 1,a + 1 + n));
//	cout << "------------------------------------" << endl;
	cin >> n;
	ll ans = 0;
	for(int i = 1;i <= n;i ++)
	{
		if(n - i < i - 1) continue;
		ans += getC(n - i,i - 1) * getC(n - i,n - i) % mod;
//		ans += fact[n - i] * inv[n - i - (i - 1)] * fact[n - i] % mod;
//		ans += _get(i - 1,n - i) * _get(n - i,n - i) % mod;
//		cout << ans << " " << i << " " << _get(i - 1,n - i) << " " << _get(n - i,n - i) << "****************" << endl;
//		cout << fact[n - i] / fact[n - i - (i - 1)] << " " << fact[n - i] << "--------------- " << fact[n - i - (i - 1)] << " " << fact[n - i] << endl;
	}
	cout << ans % mod << endl;
}
signed main()
{
	fast();
//	_
//	init();
	getFac();
	solve();
	return 0;
} 


/**
*  ┏┓   ┏┓+ +
* ┏┛┻━━━┛┻┓ + +
* ┃     A C   ┃  
* ┃   ━   ┃ ++ + + +
*  ████━████+
*  ◥██◤ ◥██◤ +
* ┃   ┻   ┃
* ┃       ┃ + +
* ┗━┓   ┏━┛
*   ┃   ┃ + + + +Code is far away from  
*   ┃   ┃ + bug with the animal protecting
*   ┃    ┗━━━┓ 神兽保佑,代码无bug 
*   ┃        ┣┓
*    ┃        ┏┛
*     ┗┓┓┏━┳┓┏┛ + + + +
*    ┃┫┫ ┃┫┫
*    ┗┻┛ ┗┻┛+ + + +
*/
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  A佛祖保佑C       
*/

详细

Test #1:

score: 0
Time Limit Exceeded

input:

1

output:


result: