QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#567585 | #5062. Square | zhouchenfeng# | WA | 6ms | 3896kb | C++14 | 791b | 2024-09-16 12:53:14 | 2024-09-16 12:53:16 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 7;
void solve() {
int n;
cin >> n;
vector<int> aa(n + 1);
for(int i = 1; i <= n; i ++) {
cin >> aa[i];
}
if(n == 1) {
cout << 1 << '\n';
return;
}
int ans;
int h = __gcd(aa[1], aa[2]);
ans = aa[1] * aa[2] / h / h % mod;
int pre = aa[1] / h;
for(int i = 2; i < n; i ++) {
int g = __gcd(aa[i], aa[i + 1]);
int x = aa[i] / g, y = aa[i + 1] / g;
int z = pre;
int g1 = __gcd(x, z), g2 = __gcd(y, z);
z /= g1, z /= g2, x /= g1, y /= g2;
pre = z * x * y;
ans = ans * pre % mod;
}
cout << ans << '\n';
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int _ = 1;
// cin >> _;
while(_ --) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
3 2 3 6
output:
6
result:
ok 1 number(s): "6"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 6ms
memory: 3896kb
input:
100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
1000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
1 130321
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
1 85849
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3568kb
input:
10 1 37249 1 193 1 193 193 193 1 37249
output:
606462037
result:
wrong answer 1st numbers differ - expected: '387487994', found: '606462037'