結果
| 問題 | No.407 鴨等素数間隔列の数え上げ |
| コンテスト | |
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2016-11-26 16:06:02 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 758 bytes |
| 記録 | |
| コンパイル時間 | 2,866 ms |
| コンパイル使用メモリ | 73,856 KB |
| 実行使用メモリ | 87,812 KB |
| 最終ジャッジ日時 | 2024-11-27 11:35:37 |
| 合計ジャッジ時間 | 20,004 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 24 TLE * 7 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int L = sc.nextInt();
int dlim = L/(N-1);
boolean [] d = new boolean [dlim+1];
for(int i=2; i<=dlim; i++){
d[i]=true;
}
for(int i=4; i<=dlim; i++){
int rt=(int)Math.sqrt(i)+1;
for(int j=2; j<=rt; j++){
if(i%j==0){
d[i]=false;
}
}
}
long ans =0;
for(int i=2; i<=dlim; i++){
if(d[i]==true){
long t=L-i*(N-1)+1;
ans+=t;
}
}
System.out.println(ans);
}
}
kohaku_kohaku