QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#757970#9738. Make It Divisibleruoye123456#WA 0ms3552kbC++201.8kb2024-11-17 14:55:582024-11-17 14:55:58

Judging History

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

  • [2024-11-27 18:44:44]
  • hack成功,自动添加数据
  • (/hack/1263)
  • [2024-11-17 14:55:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-11-17 14:55:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef vector<string> VS;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
vector<int> vx;
inline void divide() {sort(vx.begin(),vx.end());vx.erase(unique(vx.begin(),vx.end()),vx.end());}
inline int mp(int x) {return upper_bound(vx.begin(),vx.end(),x)-vx.begin();}
inline int log_2(int x) {return 31-__builtin_clz(x);}
inline int popcount(int x) {return __builtin_popcount(x);}
inline int lowbit(int x) {return x&-x;}
inline ll Lsqrt(ll x) { ll L = 1,R = 2e9;while(L + 1 < R){ll M = (L+R)/2;if(M*M <= x) L = M;else R = M;}return L;}
const int N = 50005;
ll n,k;
void solve()
{
    cin>>n>>k;
    vector<ll> arr(n);
    bool is=false;
    for(int i=0;i<n;i++) 
    {
        cin>>arr[i]; 
        if(i>=1&&arr[i]!=arr[i-1]) is=true;
    }
    if(!is)
    {
        cout<<k<<' '<<(k+1)*k/2<<'\n';
        return ;
    }
    sort(arr.begin(),arr.end());
    ll G=0;
    for(int i=1;i<n;i++)
    {
        G=gcd(G,arr[i]-arr[i-1]);
    }
    //cout<<G<<' ';
    ll sum=0,cnt=0;
    for(int i=1;i<=G/i;i++)
    {
        if(G%i) continue;
        if(i>arr[0]&&k>=i)
        {sum+=(i-arr[0]);
        cnt++;
        }
        if(G/i!=i&&G/i>arr[0]&&k>=G/i)
        {
            sum+=(G/i-arr[0]);
            cnt++;
        }
    }
    cout<<cnt<<' '<<sum<<'\n';
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
	//cin>>T;
    // for(int i=1;i<N;++i)
    // {
    //     for(int j=i;j<N;j+=i)
    //     {
    //         ++cnt[j];//约数个数
    //         sum[j]+=i;//约数个数和
    //     }
    // }
    cin>>T;
	while(T--)
	{
		solve();
	}
}

详细

Test #1:

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

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

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'