結果

問題 No.638 Sum of "not power of 2"
ユーザー horiesinitihoriesiniti
提出日時 2018-03-13 07:51:47
言語 Ruby
(3.3.0)
結果
AC  
実行時間 90 ms / 1,000 ms
コード長 208 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-28 20:18:31
合計ジャッジ時間 2,258 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
12,032 KB
testcase_01 AC 90 ms
12,032 KB
testcase_02 AC 88 ms
12,160 KB
testcase_03 AC 90 ms
12,160 KB
testcase_04 AC 88 ms
12,288 KB
testcase_05 AC 87 ms
12,160 KB
testcase_06 AC 89 ms
12,288 KB
testcase_07 AC 88 ms
12,032 KB
testcase_08 AC 89 ms
12,288 KB
testcase_09 AC 88 ms
12,032 KB
testcase_10 AC 88 ms
12,032 KB
testcase_11 AC 89 ms
12,032 KB
testcase_12 AC 88 ms
12,032 KB
testcase_13 AC 88 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:24: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

def f(n)
c1=0
while n>0
	if n%2==1
		c1+=1
	end
	n=n/2
end
return c1
end
n=gets.to_i
m=3
ok=false
while n-m>=m
	if f(n-m)>1 && f(m)>1
		ok=true
		break
	end
	m+=1
end
if ok
	puts [m,n-m]*" "
else
	puts -1
end
0