QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#567585#5062. Squarezhouchenfeng#WA 6ms3896kbC++14791b2024-09-16 12:53:142024-09-16 12:53:16

Judging History

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

  • [2024-09-16 12:53:16]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3896kb
  • [2024-09-16 12:53:14]
  • 提交

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;
}

詳細信息

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'