結果
| 問題 | No.407 鴨等素数間隔列の数え上げ |
| コンテスト | |
| ユーザー |
mudbdb
|
| 提出日時 | 2016-08-06 00:01:29 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 648 bytes |
| 記録 | |
| コンパイル時間 | 525 ms |
| コンパイル使用メモリ | 20,992 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 04:55:34 |
| 合計ジャッジ時間 | 6,792 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 29 TLE * 2 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:33:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf("%d %d",&N,&L);
| ^~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int Pr(int n) {
int e = 0;
int p;
if (n%2 == 0) {
e++;
n/=2;
if (n%2 == 0) {
return 0;
}
}
for (p=3; p*p<=n; p+=2) {
if (n%p == 0) {
if (e >= 1) {
return 0;
}
e++;
n/=p;
if (n%p == 0) {
return 0;
}
}
}
if (n != 1) {
if (e >= 1) {
return 0;
}
}
return 1;
}
int main() {
int N,L;
scanf("%d %d",&N,&L);
int i;
long long int M = 0;
if (2 <= L/(N-1)) {
M += (L - 2*(N-1) + 1);
}
for (i=3; i<=L/(N-1); i+=2) {
if (Pr(i)) {
M += (L - i*(N-1) + 1);
}
}
printf("%lld\n",M);
return 0;
}
mudbdb