General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
80821530 Practice:
StarInShadow
1355F - 23 C++17 (GCC 7-32) Accepted 62 ms 404 KB 2020-05-21 08:19:31 2020-05-21 08:19:31
→ Source
#include<bits/stdc++.h>

using namespace std;

int64_t X=1268376;
int64_t prime[400] = {
	2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,
	97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,
	191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,
	283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,
	401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,
	521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,
	643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,
	769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,
	907,911,919,929,937,941,947,953,967,971,977,983,991,997,1007
};

int64_t lim18=1e18,lim15=1e15,lim9=1e9;
vector<int64_t> plist,factors;
vector<int> pstart;

int64_t gcd(int64_t a,int64_t b) {
	return a == 0 ? b : gcd(b % a, a);
}

int factor(int64_t x,int i=0){
    int ans=1,now;
    for(;x>1;++i){
        now=1;
        while(x%prime[i]==0){
            ++now;
            x/=prime[i];
        }
        ans*=now;
    }
    return ans;
}

void add_factor(int64_t x,int i=0) {
	int now;
	for(; x>1; ++i) {
		now=1;
		while(x%prime[i]==0) {
			++now;
			x/=prime[i];
		}
		if(now>1) factors.push_back(prime[i]);
	}
}

int64_t ask(int64_t x) {
	int64_t r;
	cout<<"? "<<x<<endl;
	cout.flush();
	cin>>r;
	return r;
	//cout<<"ask "<<x<<" return "<<gcd(X,x)<<endl;
	//return gcd(X,x);
}

int main() {
	int64_t now=1,all=0;
    
	for(int i=0; prime[i]<630; ++i) {
		int64_t pi=prime[i];

		//while(pi*prime[i]<=1000) pi*=prime[i];
		now*=pi;
		if(now>lim18/prime[i+1]) {
			++all;
			//cout<<now<<endl;
			plist.push_back(now);
			pstart.push_back(i+1);
			now=1;
		}
	}
	if(now>1) ++all;
	plist.push_back(now);
	pstart.push_back(pstart.back());
	pstart.insert(pstart.begin(),0);
	//cout<<all<<endl;
	int t;
	int64_t res,r2,r3,ges,ans;
	cin>>t;
	//for(auto xx:plist) cout<<xx<<endl;
	while(t--) {
	    //cin>>X;
        factors.clear();
		ges=1;
		ans=1;
		for(int i=0; i<plist.size(); ++i) {
			res=ask(plist[i]);
			add_factor(res,pstart[i]);
			ges*=res;
			int64_t nextP=prime[pstart[i+1]];
			if(ges*nextP*nextP*nextP > 1e9){
			    if(res>1) factors.pop_back();
			    break;
			    
			}
		}
		//cout<<ges<<" ";
		while(factors.size()){
		    int64_t a=factors.back(),b=1;
		    ges/=a;
		    while(a*factors.back()<lim9) a*=factors.back();
		    factors.pop_back();
		    if(factors.size()){
		        b=factors.back();
		        ges/=b;
		        while(b*factors.back()<lim9) b*=factors.back();
                factors.pop_back();
            }
            ges*=ask(a*b);
        }
        ans=factor(ges);
		cout<<"! "<<max(ans*2,ans+7)<<endl;
		cout.flush();
	}
}







?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details