QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#739748 | #9738. Make It Divisible | HUY1# | TL | 0ms | 0kb | C++20 | 1.5kb | 2024-11-12 22:57:36 | 2024-11-12 22:57:36 |
Judging History
你现在查看的是最新测评结果
- [2024-11-27 18:44:44]
- hack成功,自动添加数据
- (/hack/1263)
- [2024-11-14 09:10:13]
- hack成功,自动添加数据
- (/hack/1178)
- [2024-11-12 22:57:36]
- 提交
answer
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define endl '\n'
#define MAXN 40005
ll a[MAXN],b[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);
if (n == 1) {
cout << k << " " << k * (k + 1) / 2 << endl;
return;
}
ll res1=0,ct1=0;
for(int i=1;i<=k;i++){
for(int j=1;j<=n;j++){
b[j]=a[j]+i;
}
bool f=1;
for(int k=1;k<=n-1;k++){
if(b[n]%b[k]){
f=0;break;
}
}
if(f) res1+=i,ct1++;
}
// ll x = a[n];
// map<ll, bool> mp, st;
// for (int i = 1; i <= n - 1; i++) {
// ll y = a[i];
// ll t = x - y;
//
// if (i == 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;
cout<<ct1<<" "<<res1<<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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
3 5 10 7 79 1 7 1 2 1000000000 1 2 1 100 1000000000