QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#758238#9738. Make It Divisibleruoye123456#WA 0ms3796kbC++202.1kb2024-11-17 17:01:572024-11-17 17:01:58

Judging History

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

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

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<int> a(n);
    vector<ll> arr(n);
    bool is=false;
    for(int i=0;i<n;i++) 
    {
        cin>>arr[i]; 
        a[i] = 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;
    vector<int> ans;
    for(int i=1;i*i<=G;i++)
    {
        if(G%i) continue;
        if(i>arr[0]&&k>=i)
        {
        ans.push_back(i - arr[0]);
        }
        if(G/i!=i&&G/i>arr[0]&&k>=G/i)
        {
            ans.push_back(G/i - arr[0]);
        }
    }
    for(auto u:ans)
    {
        bool ok = true;
        for(int i=0;i<n-1;++i)
        {
            if((a[i]+u)%(a[i+1]+u)&&(a[i+1]+u)%(a[i]+u)) {ok = false;break;}
        }
        if(ok) sum += u, 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: 3792kb

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

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'