QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#275285#7260. RopesPetroTarnavskyi#WA 1ms3440kbC++20792b2023-12-04 16:12:202023-12-04 16:12:20

Judging History

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

  • [2023-12-04 16:12:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3440kb
  • [2023-12-04 16:12:20]
  • 提交

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 = 1'000'000'007;
const int inv2 = (mod + 1) / 2;

int mult(int a, int b)
{
	return (LL)a * b % mod;
}

int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0);
	int n;
	cin >> n;
	int ans = 1;
	FOR(i, 1, n - 1)
		ans = mult(ans, i);
	FOR(i, 0, n)
	{
		int a;
		cin >> a;
		if (a == 3)
			ans = mult(ans, inv2);
	}
	cout << ans << "\n";
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3344kb

input:

9
1
3
2
1
3
1
2
1
2

output:

1260

result:

ok 1 number(s): "1260"

Test #2:

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

input:

9
1
2
1
1
3
2
1
3
2

output:

1260

result:

ok 1 number(s): "1260"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3392kb

input:

5
3
3
3
3
3

output:

687500005

result:

wrong answer 1st numbers differ - expected: '0', found: '687500005'