結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー Hank
提出日時 2016-05-24 21:36:18
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 424 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 24,064 KB
実行使用メモリ 22,784 KB
最終ジャッジ日時 2024-10-07 06:46:23
合計ジャッジ時間 3,825 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 12 WA * 6 TLE * 1 -- * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |   scanf("%ld %ld",&a,&b);
      |   ^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
  long  a,b,i,j,*r;
  long result = 0;
  scanf("%ld %ld",&a,&b);
  r=(long*)malloc(sizeof(long)*(b-a+1));
  for(i=a;i<=b;i++){
    r[i-a]=0;
    for(j=2;j<sqrt(i);j++){
      if(i%j==0){
	r[i-a]=j;
	break;
      }
    }
  }
  j=0;
  for(i=a;i<=b;i++){
    if(r[i-a]>=j){
      j=r[i-a];
      result = i;
    }
  }
  printf("%ld\n",result);
  return 0;
}
0