結果
| 問題 |
No.407 鴨等素数間隔列の数え上げ
|
| コンテスト | |
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2016-12-04 04:12:50 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 180 ms / 1,000 ms |
| コード長 | 653 bytes |
| コンパイル時間 | 2,521 ms |
| コンパイル使用メモリ | 74,492 KB |
| 実行使用メモリ | 46,072 KB |
| 最終ジャッジ日時 | 2024-12-16 01:47:34 |
| 合計ジャッジ時間 | 8,734 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 31 |
ソースコード
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 [] b = new boolean [dlim+1];
long count=0L;
if(dlim>=2){
count+=L-2*(N-1)+1;
}
for(int i=3; i<=dlim; i+=2){
if(b[i]==false){
count+=L-i*(N-1)+1;
int k=2;
while(i*k<=dlim){
b[i*k]=true;
k++;
}
}
}
System.out.println(count);
}
}
kohaku_kohaku