結果

問題 No.36 素数が嫌い!
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-17 03:42:16
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 762 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 26,256 KB
実行使用メモリ 15,868 KB
最終ジャッジ日時 2023-09-22 16:53:45
合計ジャッジ時間 8,565 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 AC 123 ms
11,424 KB
testcase_03 AC 120 ms
11,536 KB
testcase_04 AC 118 ms
11,544 KB
testcase_05 AC 117 ms
11,488 KB
testcase_06 AC 118 ms
11,484 KB
testcase_07 AC 118 ms
11,424 KB
testcase_08 WA -
testcase_09 AC 116 ms
11,616 KB
testcase_10 WA -
testcase_11 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <math.h>
#include <string.h>
#include <stdio.h>

char prime[10001000];

void getPrime(int p){
	int i,j;
	for(i=0;i<p;i++){
		prime[i] = 1;
		if((i&1) == 0){
			prime[i] = 0;
		}
	}
	
	prime[0]=0;
	prime[1]=1;
	prime[2]=1;
	
	for(i=3;i*i<=p;i+=2){
		for(j=i+i;j<=p;j+=i){
			prime[j]=0;
		}
	}
}

int main(void){
	long long int n,tmp;
	int i, p = 10000000 + 1;
	int yes=0;
	getPrime(p);
	
	scanf("%lld", &n);
	
	for(i=2;i*i<=n;i++){
		if(n%i == 0){
			if(prime[i]==1){
				
				int cnt=0;
				tmp = n;
				while(tmp%i == 0){
					tmp/=i;
					cnt++;
				}
				if(cnt>2){
					yes=1;
					break;
				}
				
			}else{
				printf("%d\n", i);
				yes = 1;
				break;
			}
		}
	}
	
	if(yes == 1){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	
	return 0;
}
0