結果
| 問題 |
No.36 素数が嫌い!
|
| コンテスト | |
| ユーザー |
TLwiegehtt
|
| 提出日時 | 2015-07-17 03:38:00 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 759 bytes |
| コンパイル時間 | 298 ms |
| コンパイル使用メモリ | 22,784 KB |
| 実行使用メモリ | 16,512 KB |
| 最終ジャッジ日時 | 2024-07-08 08:20:05 |
| 合計ジャッジ時間 | 12,863 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | AC * 3 WA * 1 RE * 2 TLE * 1 -- * 19 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:33:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf("%lld", &n);
| ^~~~~~~~~~~~~~~~~
ソースコード
#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<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;
}
TLwiegehtt