QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#197651#6890. GuesshazeWA 85ms34336kbC++232.0kb2023-10-02 18:02:032023-10-02 18:02:03

Judging History

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

  • [2023-10-02 18:02:03]
  • 评测
  • 测评结果:WA
  • 用时:85ms
  • 内存:34336kb
  • [2023-10-02 18:02:03]
  • 提交

answer

#include<bits/stdc++.h>
#define irep(i,l,r) for(int i = l; i <= r; ++i)
#define drep(i,r,l) for(int i = r; i >= l; --i)
#define ceil(pp,qq) (((pp)>0)^((qq)>0)?-Abs(pp)/Abs(qq):(pp)%(qq)?(pp)/(qq)+1:(pp)/(qq))
#define floor(pp,qq) (((pp)>0)^((qq)>0)?-ceil(abs(pp),abs(qq)):(pp)/(qq))
#define ll long long
#define LL __int128
using namespace std;
ll Abs(ll x){return x > 0 ? x : - x;}
inline ll read(){
	char ch = getchar();
	ll s = 0; bool w = 0;
	while(!isdigit(ch)){if(ch == '-')w = 1;ch = getchar();}
	while(isdigit(ch))s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
	return w ? - s : s;
}

const int itinf = 2e9;
const ll llinf = 4e18;
const int mod = 998244353;
const int N = 500009;

ll qpow(LL a, ll b, LL md){
	LL ans = 1;
	while(b){
		if(b & 1)ans *= a, ans %= md;
		a *= a, a %= md, b >>= 1;
	}
	return ans;
}

bool check(ll n) {
  if (n < 3 || n % 2 == 0) return n == 2;
  ll u = n - 1, t = 0;
  while (u % 2 == 0) u /= 2, ++t;
  for (int i = 0; i < 8; ++i) {
    ll a = rand() % (n - 2) + 2, v = qpow(a, u, n);
    if (v == 1) continue;
    ll s;
    for (s = 0; s < t; ++s) {
      if (v == n - 1) break; 
      v = (long long)v * v % n;
    }
    if (s == t) return 0;
  }
  return 1;
}

int isp[1000999] = {1,1};
vector<int>pri;
set<ll>avl;
map<ll,int>mp;
int main(){
	int pmax = 1000000;
	for(int i = 2; i <= pmax; ++ i){
		if(! isp[i])pri.push_back(i);
		for(int p : pri){
			if(1ll * i * p > pmax)break;
			isp[i * p] = 1;
		}
	}
	
	for(ll p : pri){
		for(LL t0 = p; t0 <= llinf; t0 *= p){
			avl.insert(t0);
			mp[t0] = p;
		}
	}

	int T = read();
	while(T --){
		ll n = read();
		
		if(check(n)){
			printf("%lld ", n % mod);
			continue;
		}
		ll k = sqrt(n);
		if((k + 1) * (k + 1) == n) ++ k;
		if(k * k == n){
			if(check(k))printf("%lld ", k % mod);
			else printf("%lld ", 1);
			continue;
		}
		if(avl.find(n) == avl.end())printf("1 ");
		else printf("%lld ",(mp[n]) % mod);
	}
	
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 85ms
memory: 34336kb

input:

2000
19491001 1 998244353 26952597531 861547697451441000 996491788296388609 981763655235363000 1024000007168 996491787298144256 973929762490885200 891042123129958800 878912224686896400 804111184288011600 766710664088569200 930867627131442000 996491787298144256 812033461965726000 964953451315854000 8...

output:

19491001 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

result:

wrong answer 1st lines differ - expected: '19491001 1 0 1 1 0 1 1 1 1 1 1...66159 899999557 1 716046715 1 1', found: '19491001 1 0 1 1 0 1 1 1 1 1 1... 899999759 1 899999557 1 1 1 1 '