QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#864994#9738. Make It Divisiblexjt05WA 1ms5872kbC++232.3kb2025-01-21 13:18:132025-01-21 13:18:14

Judging History

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

  • [2025-01-21 13:18:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5872kb
  • [2025-01-21 13:18:13]
  • 提交

answer

#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<deque>
#include<cctype>
#include<string.h>
#include<math.h>
#include<time.h>
#include<random>
#include<stack>
#include<string>
//#include<bits/stdc++.h>
#include <unordered_map>
#define ll                                   long long
#define lowbit(x) (x & -x)
#define endl "\n"//                           交互题记得删除
using namespace std;
mt19937 rnd(time(0));
const ll mod = 998244353;
//const ll p=rnd()%mod;
ll ksm(ll x, ll y)
{
	ll ans = 1;
	while (y)
	{
		if (y & 1)
		{
			ans = ans % mod * (x % mod) % mod;
		}
		x = x % mod * (x % mod) % mod;
		y >>= 1;
	}
	return ans % mod % mod;
}
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	else
		return gcd(y, x % y);
}
void fio()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll a[650000];
ll b[650000];
set<pair<ll,ll>>p;
set<ll>q;
vector<ll>op;
int main()
{
	fio();
	ll t;
	cin>>t;
	while(t--)
	{
		op.clear();
		q.clear();
		p.clear();
		   ll n,f;
	       cin>>n>>f;
		   ll gs=0;
		   for(ll i=1;i<=n;i++)
		   {
			cin>>a[i];
			if(a[i]==a[1])
			gs++;
	       }
			if(gs==n)
			{
				cout<<f<<" "<<(1+f)*f/2<<endl;
				continue;
			}
			set<ll>q;
			ll ko=0;
			ll zk,zr;
			for(ll i=1;i<n;i++)
			{
				ll l=a[i],r=a[i+1];
				if(l>r)
				swap(l,r);
				if(l==r)continue;
				p.insert({l,r});
				if(i+2<=n&&a[i]!=a[i+2])
				{
					ll u=a[i],j=a[i+2];
					if(u>j)swap(u,j);
				p.insert({u,j});
				}
			}
			for(auto j:p)
			{
				ll l=j.first,r=j.second;
				//cout<<l<<" "<<r<<endl;
				op.clear();
				if(ko==0)
				{
					r-=l;
					for(ll u=1;u*u<=r;u++)
					{
						if(r%u==0)
						{
							if(u-l>=1&&u-l<=f)
							{
								q.insert(u-l);
							}
							if(r/u-l>=1&&r/u-l<=f) 
							{
								q.insert(r/u-l);
							}
						}
					}
					ko=1;
				}
				else 
				{
					for(auto k:q)
					{
						if((r+k)%(l+k)==0)
						{
							continue;
						}
						else 
						{
							op.push_back(k);
						}
					}
					for(auto k:op)
					q.erase(k);
					if(q.size()==0)
					break;
				}
			} 
			ll ans=0;
			for(auto j:q)
			{
				ans+=j;
			}
			cout<<q.size()<<" "<<ans<<endl;
	}
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5820kb

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: 0
Accepted
time: 1ms
memory: 5852kb

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
0 0
0 0
0 0

result:

ok 4 lines

Test #3:

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

input:

500
4 1000000000
8 14 24 18
4 1000000000
17 10 18 14
4 1000000000
6 17 19 19
4 1000000000
15 14 15 25
4 1000000000
16 16 5 25
4 1000000000
4 30 20 5
4 1000000000
11 4 23 9
4 1000000000
14 25 13 2
4 1000000000
18 18 1 15
4 1000000000
22 22 22 28
4 1000000000
15 17 17 10
4 1000000000
22 14 13 25
4 100...

output:

0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
1 1
0 0
0 0
0 0
0 0
0 0
0 0
0 0
...

result:

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