結果
問題 | No.36 素数が嫌い! |
ユーザー |
|
提出日時 | 2015-07-21 08:37:00 |
言語 | C90 (gcc 12.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 556 bytes |
コンパイル時間 | 812 ms |
コンパイル使用メモリ | 23,808 KB |
実行使用メモリ | 7,040 KB |
最終ジャッジ日時 | 2024-07-08 11:31:00 |
合計ジャッジ時間 | 7,267 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | AC * 1 TLE * 1 -- * 24 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%lld", &n); | ^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <math.h> int main(void) { unsigned long long int i = 0; unsigned long int j = 0; unsigned char usable = 0; unsigned char is_prime = 1; unsigned long long int n = 0; scanf("%lld", &n); /* 素数判定 */ for ( i=2; i<=(n/2); i++ ) { is_prime = 1; for ( j=2; j<=sqrt(i); j++ ) { if ( !(i % j) ) { is_prime = 0; break; } } if ( is_prime == 1 ) { continue; } if ( !(n % i) ) { usable = 1; break; } } if ( usable ) { printf("YES\n"); } else { printf("NO\n"); } return 0; }