結果

問題 No.278 連続する整数の和(2)
ユーザー kkkk
提出日時 2015-09-19 07:07:45
言語 PHP
(8.2.11)
結果
WA  
実行時間 -
コード長 381 bytes
コンパイル時間 911 ms
コンパイル使用メモリ 18,456 KB
実行使用メモリ 19,080 KB
最終ジャッジ日時 2023-09-26 13:31:34
合計ジャッジ時間 2,657 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
18,888 KB
testcase_01 WA -
testcase_02 AC 15 ms
18,720 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php

$input = trim(fgets(STDIN));

//割り切れる数の最大値
$multiple_max = 1;

if (($input%2)==0){
    $multiple_max = $input / 2;
}else{
    $multiple_max = $input;
}

//集計
$mp  = $multiple_max;

//対象値
$max = $multiple_max;

do{
	if ($max%2==0){
	    $max = $max / 2;
	    $mp += $max;
	}else{
		$max = 0;
		$mp = $mp + 1;
	}
}while($max>0);

echo $mp . "\n";
0