QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#739625#9738. Make It DivisibleHUY1#WA 0ms3816kbC++201.2kb2024-11-12 22:27:202024-11-12 22:27:21

Judging History

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

  • [2024-11-27 18:44:44]
  • hack成功,自动添加数据
  • (/hack/1263)
  • [2024-11-14 09:10:13]
  • hack成功,自动添加数据
  • (/hack/1178)
  • [2024-11-12 22:27:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3816kb
  • [2024-11-12 22:27:20]
  • 提交

answer

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define endl '\n'
#define MAXN 40005
ll a[MAXN];
void solve()
{
	ll n, k;
	cin >> n >> k;
	
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	
	sort(a + 1, a + n + 1);
	n = unique(a + 1, a + n + 1) - a - 1;
	

	if (n == 1) {
		cout << k << " " << k * (k + 1) / 2 << endl;	
		return;
	}
	
	ll x = a[n];
	map<ll, bool> mp, st;
	for (int i = n - 1; i >= 1; i--) {
		ll y = a[i];
		ll t = x - y;
		
		if (i == n - 1) {
			for (int j = 1; j <= t / j; j++) {
				if (t % j == 0) {
					if (j > y) {
						mp[j - y] = 1;
					}
					if (t / j != j) {
						if (t / j > y) {
							mp[t / j - y] = 1;
						}
					}
				}
			}
		} else {
			for (auto k : mp) {
				if (t % (k.first + y) != 0) {
					st[k.first] = 1;
				}
			}
		}
	}
	
	ll res = 0, cnt = 0;
	for (auto k : mp) {
		if (!st[k.first]) {
			res += k.first;
			cnt++;
		}
	}
	
	cout << cnt << ' ' << res << endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int t = 1;
	cin >> t;
	
	while (t--) {
		solve();
	}
	
	return 0;
}
/*
3
5 10
7 79 1 7 1
2 1000000000
1 2
1 100
1000000000
 */

詳細信息

Test #1:

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

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: 3816kb

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:

1 1
1 1
1 1
1 1

result:

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