結果
| 問題 |
No.407 鴨等素数間隔列の数え上げ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-30 22:30:13 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 516 bytes |
| コンパイル時間 | 306 ms |
| コンパイル使用メモリ | 24,704 KB |
| 実行使用メモリ | 12,160 KB |
| 最終ジャッジ日時 | 2024-11-21 11:17:48 |
| 合計ジャッジ時間 | 43,922 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 TLE * 1 |
| other | AC * 11 TLE * 20 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:25:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | scanf("%d %d",&n,&l);
| ^~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<math.h>
#include<stdbool.h>
bool checkprime(int n){
int i;
if(n == 2) return true;
else if(n%2 == 0) return false;
for(i=3;i<=sqrt(n);i=i+2){
if(n%i == 0){
return false;
break;
}
}
return true;
}
int main(void){
int n,l,i;
double cnt=0;
scanf("%d %d",&n,&l);
int templ=l;
for(i=2;i<l;i++){
if(checkprime(i)){
while(1){
if(i*(n-1) <= templ){
cnt++;
templ--;
}
else break;
}
templ = l;
}
}
printf("%.f\n",cnt);
return 0;
}