QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#830279#9426. Relearn through ReviewLaVuna47#WA 138ms3592kbC++172.1kb2024-12-24 17:51:402024-12-24 17:51:40

Judging History

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

  • [2024-12-24 17:51:40]
  • 评测
  • 测评结果:WA
  • 用时:138ms
  • 内存:3592kb
  • [2024-12-24 17:51:40]
  • 提交

answer

/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, st_, n) for(int i = st_; i < n; ++i)
#define RFOR(i, n, end_) for(int i = (n)-1; i >= end_; --i)
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

// 3 5 10 14 18 20 24
// 0 0 0 0 0 0 0 0 10 10 10 10 0 0 0 0
// g=14, k = 4
int solve()
{
	ll n, k;
	if(!(cin>>n>>k))return 1;
	vector<ll> a(n);
	FOR(i,0,n) cin>>a[i];
	vector<ll> pref(n,0);
	pref[0]=a[0];
	FOR(i,1,n)pref[i]=gcd(pref[i-1],a[i]);
	vector<ll> suf(n+1,0);
	suf[n-1]=a[n-1];
	RFOR(i,n-1,0)suf[i]=gcd(suf[i+1],a[i]);
	//FOR(i,0,n)cout<<pref[i]<<" ";
	//cout<<'\n';
	//FOR(i,0,n)cout<<suf[i]<<" ";
	//cout<<'\n';
	
	set<ll> S;
	ll res=suf[0];
	FOR(i,0,n)
	{
		if(S.find(pref[i])==S.end())
		{
			S.insert(pref[i]);
			ll g=0;
			for(int j=i+1; j<n; ++j)
			{
				g=gcd(g, a[j]+k);
				res=max(res,gcd(g,gcd(pref[i],suf[j+1])));
			}
		}
	}
	cout<<res<<'\n';
    return 0;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int TET = 1e9;
    cin >> TET;
    for (int i = 1; i <= TET; i++)
    {
        if (solve())
        {
            break;
        }
#ifdef ONPC
        cout << "__________________________" << endl;
#endif
    }
#ifdef ONPC
    cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}

详细

Test #1:

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

input:

2
6 2
5 3 13 8 10 555
3 0
3 6 9

output:

5
3

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 138ms
memory: 3560kb

input:

100000
1 608611451460421713
33155506392034032
1 743116173559300609
6138108577573005
7 364454564010802125
657035115675878115 657035115675878115 657035115675878115 657035115675878115 657035115675878115 292580551665075990 657035115675878115
4 316648374341335221
365788422120542814 182894211060271407 731...

output:

33155506392034032
6138108577573005
15
3
880411769063535667
98423435849394582
1
962990836390050009
484915690810412536
878097339332572161
149180825015886938
361813583202892479
915781395066183375
37337367838628559
1
1
2
494408344393555851
1
414849785128019057
118387461231999184
1
1
963758727749334806
1...

result:

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