QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#527951#5062. SquareHadtstiWA 6ms9524kbC++141.2kb2024-08-23 00:06:512024-08-23 00:06:51

Judging History

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

  • [2024-08-23 00:06:51]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:9524kb
  • [2024-08-23 00:06:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
int n,x,ans=1;
int p[1010],cnt;
bitset<1010>S;
unordered_map<int,int>v[100010];
unordered_map<int,vector<int> >T;
int power(int a,int b)
{
	int res=1;
	for(;b;b>>=1)
	{
		if(b&1)
			res=1ll*res*a%mod;
		a=1ll*a*a%mod;
	}
	return res;
}
int main()
{
	for(int i=2;i<=1000;i++)
		if(!S[i])
		{
			p[++cnt]=i;
			for(int j=i;j<=1000/i;j++)
				S[i*j]=1;
		}
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		for(int j=1;j<=cnt&&p[j]<=x/p[j];j++)
			if(x%p[j]==0)
			{
				int ct=0;
				while(x%p[j]==0)
				{
					ct++;
					x/=p[j];
				}
				v[i][p[j]]=ct;
			}
		if(x>1)
			v[i][x]=1;
	}
	for(int i=1;i<n;i++)
		for(pair<int,int>j:v[i])
		{
			if(i>1&&!v[i-1][j.first]&&j.second&1)
				T[j.first].push_back(i-1);
			if(j.second+v[i+1][j.first]&1)
				T[j.first].push_back(i);
		}
	for(pair<int,vector<int> >i:T)
	{
		int w=1,sum=0;
		for(int j=1;j<i.second.size();j++)
		{
			w^=1;
			if(!w)
				sum+=i.second[j]-i.second[j-1];
		}
		if(w)
			sum+=n-i.second.back();
		ans=1ll*ans*power(i.first,min(sum,n-sum))%mod;
	}
	printf("%d",ans);
	return 0;
}

详细

Test #1:

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

input:

3
2 3 6

output:

6

result:

ok 1 number(s): "6"

Test #2:

score: 0
Accepted
time: 0ms
memory: 9524kb

input:

1
1

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 6ms
memory: 9240kb

input:

100000
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 1 1 1 1 1 1...

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 9260kb

input:

1000
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 1 1 1 1 1 1 1...

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 0ms
memory: 9244kb

input:

1
130321

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 0
Accepted
time: 2ms
memory: 9324kb

input:

1
85849

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 0ms
memory: 9308kb

input:

10
1 37249 1 193 1 193 193 193 1 37249

output:

387487994

result:

ok 1 number(s): "387487994"

Test #8:

score: 0
Accepted
time: 2ms
memory: 9496kb

input:

10
130321 130321 6859 6859 6859 19 19 130321 361 6859

output:

130321

result:

ok 1 number(s): "130321"

Test #9:

score: -100
Wrong Answer
time: 2ms
memory: 9324kb

input:

10
1 418609 1 418609 1 1 647 418609 1 1

output:

270840023

result:

wrong answer 1st numbers differ - expected: '647', found: '270840023'