結果

問題 No.144 エラトステネスのざる
コンテスト
ユーザー 37zigen
提出日時 2016-03-22 01:50:35
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
TLE  
実行時間 -
コード長 684 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,460 ms
コンパイル使用メモリ 81,900 KB
実行使用メモリ 59,292 KB
最終ジャッジ日時 2026-04-17 14:08:14
合計ジャッジ時間 6,289 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 1 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package yukicoder242;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		double p=sc.nextDouble();
		
		int[] a=theNumberOfDivisors(n);//a[n]=nの約数の個数
//		for(int i=0;i<=n;i++){
//			System.out.println("a["+i+"]="+a[i]);
//		}
		double expectedValue=0;
		for(int i=2;i<=n;i++){
			expectedValue+=Math.pow(1-p, a[i]);
		}
		System.out.println(expectedValue);
	}
	public static int[] theNumberOfDivisors(int n){//1と自分自身を除く約数の個数
		int[] a=new int[n+1];
		for(int i=2;i<=n;i++){
			for(int j=2;j<i;j++){
				if(i%j==0)a[i]++;
			}
		}
		return a;
	}
}
0