QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#245033#7662. Kaldorian KnightsYarema#WA 6ms7492kbC++171.1kb2023-11-09 18:03:332023-11-09 18:03:34

Judging History

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

  • [2023-11-09 18:03:34]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:7492kb
  • [2023-11-09 18:03:33]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

const int mod = 1000'000'007;

int add(int a, int b)
{
	return a + b < mod ? a + b : a + b - mod;
}
int sub(int a, int b)
{
	return a - b >= 0 ? a - b : a - b + mod;
}
int mult(int a, int b)
{
	return (LL)a * b % mod;
}
const int N = 1'000'447;
int fact[N];

int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0);
	cout << fixed << setprecision(15);
	
	fact[0] = 1;
	FOR (i, 1, N) fact[i] = mult(fact[i - 1], i);
	
	int n;
	cin >> n;
	int k;
	cin >> k;
	int ans = fact[n];
	int sum = 0;
	FOR (i, 0, k)
	{
		int x;
		cin >> x;
		sum += x;
		int l = fact[n - sum];
		int r = fact[sum];
		if (i)
			r = sub(r, mult(l, mult(fact[x], fact[sum - x])));
		ans = sub(ans, mult(l, r));
	}
	cout << ans << '\n';
	
	
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 7324kb

input:

3 0

output:

6

result:

ok single line: '6'

Test #2:

score: 0
Accepted
time: 6ms
memory: 7292kb

input:

4 1
3

output:

18

result:

ok single line: '18'

Test #3:

score: 0
Accepted
time: 6ms
memory: 7440kb

input:

4 2
2
1

output:

16

result:

ok single line: '16'

Test #4:

score: 0
Accepted
time: 0ms
memory: 7492kb

input:

10 1
10

output:

0

result:

ok single line: '0'

Test #5:

score: -100
Wrong Answer
time: 3ms
memory: 7332kb

input:

10 10
1
1
1
1
1
1
1
1
1
1

output:

679483513

result:

wrong answer 1st lines differ - expected: '0', found: '679483513'