結果

問題 No.136 Yet Another GCD Problem
ユーザー 184184
提出日時 2015-01-26 00:02:45
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 659 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 39,552 KB
実行使用メモリ 11,860 KB
最終ジャッジ日時 2023-09-05 06:46:10
合計ジャッジ時間 12,894 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <cstdlib> 
#include <algorithm>
 
using namespace std;

//namaega184


int main(){
	int n,k;scanf("%d%d",&n,&k);
	int isp[100001]={0,0,1};
	for(int i=3;i<=n;i++)if(i&1)isp[i]=1;else isp[i]=0;
	for(int i=3;i*i<=n;i+=2){
		if(isp[i]){
			for(int j=i*i;j<=n;j+=i)isp[j]=0;
		}
	}
	if(n%2==0){
		printf("%d\n",n/2);
		return 0;
	}
	else{
		int cnt=0;
		for(int i=3;i*i<=n;i+=2){
			if(!isp[i])continue;
			if(n%i==0){
				cnt=0;
				int nn=n;
				while(n!=1){nn/=n;cnt++;}
				int ans=i;
				cnt/=2;
				for(int i=1;i<cnt;i++)ans*=i;
				printf("%d\n",ans);
				return 0;
			}
		}
	}
	printf("%d\n",1);
 
	return 0;
}
0