QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#275285 | #7260. Ropes | PetroTarnavskyi# | WA | 1ms | 3440kb | C++20 | 792b | 2023-12-04 16:12:20 | 2023-12-04 16:12:20 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'