记录详情

Time Exceeded


  
# 状态 耗时 内存占用
#1 Accepted 3ms 2.367 MiB
#2 Accepted 2ms 2.25 MiB
#3 Accepted 3ms 2.25 MiB
#4 Accepted 3ms 2.25 MiB
#5 Accepted 4ms 2.25 MiB
#6 Time Exceeded ≥1003ms ≥117.625 MiB
#7 Accepted 700ms 83.75 MiB
#8 Time Exceeded ≥1004ms ≥117.625 MiB
#9 Accepted 992ms 115.0 MiB
#10 Accepted 620ms 72.719 MiB

代码

#include<iostream>
#include<cstdio>
#include<cmath>
#define Ll long long
using namespace std;
const int M=1e8;
int q[5761456],tot;
bool com[M+5];
int n,mo=1000000007,x;
Ll ans;
void findcom(){
    com[1]=1;
    for(int i=2;i<=n;i++){
        if(!com[i]){q[++tot]=i;}
        for(int j=1;j<=tot;j++){
            if(i*q[j]>n)break;
            com[i*q[j]]=1;
            if(i%q[j]==0)break;
        }
    }
}
Ll ksm(int x,int y){
	Ll ans=1;
	while(y>0){
		if(y&1)ans=ans*x;
		y=y>>1;
		x=x*x;
		if(x>=mo)x%=mo;
		if(ans>=mo)ans%=mo;
	}
	return ans;
}
int main(){
    scanf("%d",&n);
    findcom();
    ans=1;
    for(int i=1;i<=tot;i++){
    	x=q[i];
    	if(x>n)break;
    	int y=log(n)/log(x);
    	ans=ans*ksm(x,y);
    	if(ans>=mo)ans%=mo;
    }
    printf("%d",int(ans));
}

信息

递交者
类型
递交
题目
篝题
语言
C++
递交时间
2017-05-02 10:59:39
评测时间
2017-05-02 10:59:39
评测机
分数
80
总耗时
≥4337ms
峰值内存
≥117.625 MiB