QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#770058#9738. Make It DivisiblemapleKingWA 0ms3756kbC++201.1kb2024-11-21 20:27:382024-11-21 20:27:39

Judging History

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

  • [2024-11-27 18:44:44]
  • hack成功,自动添加数据
  • (/hack/1263)
  • [2024-11-21 20:27:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3756kb
  • [2024-11-21 20:27:38]
  • 提交

answer

#include <bits/stdc++.h>
#pragma GCC optimize(2)

// using namespace std;

using i64 = long long;
using u32 = unsigned int;
using u64 = unsigned long long;

void solve() {
    int n, k;
    std::cin >> n >> k;
    std::vector<int> a(n);
    int mn = 1e9;
    for(int i = 0; i < n; i++){
    	std::cin >> a[i];
    	mn = std::min(mn, a[i]);
    }
    int g = 0;
    for(int i = 1; i < n; i++){
    	g = std::gcd(g, std::abs(a[i] - a[i - 1]));
    }
    if (g == 0){
    	std::cout << k << " " << 1LL * k * (k + 1) / 2 << "\n";
    	return;
    }
    i64 ans = 0, cnt = 0;
    for(int i = 1; i * i <= g; i++){
    	if (g % i == 0){
    		int j = g / i;
    		if (i > mn){
    			cnt++;
    			ans += i - mn;
    		}
    		if (j > mn){
    			cnt++;
    			ans += j - mn;
    		}
    	}
    }
    std::cout << cnt << " " << ans << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    // std::cout << std::fixed << std::setprecision(10); // 固定输出精度
    int t = 1;
    std::cin >> t;

    while (t--) {
        solve();
    }
    

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
5 10
7 79 1 7 1
2 1000000000
1 2
1 100
1000000000

output:

3 8
0 0
100 5050

result:

ok 3 lines

Test #2:

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

input:

4
201 1000000000
1 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5...

output:

0 0
1 1
0 0
0 0

result:

wrong answer 2nd lines differ - expected: '0 0', found: '1 1'