记录详情

Time Exceeded


  
# 状态 耗时 内存占用
#1 Wrong Answer 3ms 2.336 MiB
#2 Wrong Answer 3ms 2.25 MiB
#3 Wrong Answer 3ms 2.34 MiB
#4 Wrong Answer 5ms 2.25 MiB
#5 Wrong Answer 10ms 2.25 MiB
#6 Time Exceeded ≥1003ms ≥118.625 MiB
#7 Time Exceeded ≥1001ms ≥97.0 MiB
#8 Time Exceeded ≥1003ms ≥117.625 MiB
#9 Time Exceeded ≥1002ms ≥116.875 MiB
#10 Time Exceeded ≥1005ms ≥85.617 MiB

代码

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<cstring>
#include<vector>
#define inf 1e9
#define ll long long
#define For(i,j,k) for(ll i=j;i<=k;i++)
#define Dow(i,j,k) for(ll i=k;i>=j;i--)
using namespace std;
ll mo=1000000007;
ll n,tot,pri[10000001],ans;
bool bj[100000001];
void get_pri()
{
	For(i,2,n)
	{
		if(!bj[i])	
			pri[++tot]=i;
		For(j,1,tot)
		{
			if(i*pri[j]>n)	break;
			bj[i*pri[j]]=1;
			if(i%pri[j]==0)	break;
		}
	}
}
ll ksm(ll x,ll y)
{
	ll sum=1;for(;y;y<<=1){if(y&1)sum*=x%mo;x*=x%mo;}	return sum;
}
int main()
{
	scanf("%lld",&n);
	get_pri();
	ans=1;
	For(i,1,tot)
	{
		ll num=pri[i];
	//	cout<<num<<endl;
		ll t=log(n)/log(num);
		For(i,1,t)	ans=(ans*ksm(num,t))%mo;
	}
	printf("%lld\n",ans);
}

信息

递交者
类型
递交
题目
篝题
语言
C++
递交时间
2017-05-02 10:42:51
评测时间
2017-05-02 10:42:51
评测机
分数
0
总耗时
≥5043ms
峰值内存
≥118.625 MiB