結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー mudbdbmudbdb
提出日時 2016-08-06 00:18:19
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 43 ms / 1,000 ms
コード長 578 bytes
コンパイル時間 1,005 ms
コンパイル使用メモリ 25,504 KB
実行使用メモリ 6,672 KB
最終ジャッジ日時 2023-08-22 04:32:25
合計ジャッジ時間 2,561 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 0 ms
4,380 KB
testcase_07 AC 0 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 0 ms
4,376 KB
testcase_11 AC 0 ms
4,376 KB
testcase_12 AC 0 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 0 ms
4,380 KB
testcase_15 AC 0 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 0 ms
4,380 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 12 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 0 ms
4,380 KB
testcase_25 AC 22 ms
4,380 KB
testcase_26 AC 0 ms
4,380 KB
testcase_27 AC 0 ms
4,380 KB
testcase_28 AC 0 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 0 ms
4,380 KB
testcase_32 AC 9 ms
4,380 KB
testcase_33 AC 43 ms
6,672 KB
testcase_34 AC 40 ms
6,604 KB
testcase_35 AC 20 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
char *P = 0;
int Pr(int n) {
  P = (char*)malloc(sizeof(char)*(n+1));
  int i;
  int j;
  for (i=0; i<=n; i++) P[i] = 1;
  P[0] = 0;
  P[1] = 0;
  for (i=2; i<=n; i++) {
    if (P[i] == 1) {
      for (j=i*2; j<=n; j+=i) {
        P[j] = 0;
      }
    }
  }
}
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);
  }
  Pr(L/(N-1));
  for (i=3; i<=L/(N-1); i+=2) {
    if (P[i] == 1) {
      M += (L - i*(N-1) + 1);
    }
  }
  printf("%lld\n",M);
  return 0;
}
0