結果

問題 No.638 Sum of "not power of 2"
ユーザー 👑 horiesinitihoriesiniti
提出日時 2018-03-13 07:51:47
言語 Ruby
(3.3.0)
結果
AC  
実行時間 82 ms / 1,000 ms
コード長 208 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 11,468 KB
実行使用メモリ 15,224 KB
最終ジャッジ日時 2023-08-11 03:15:03
合計ジャッジ時間 3,224 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,204 KB
testcase_01 AC 80 ms
15,212 KB
testcase_02 AC 81 ms
15,224 KB
testcase_03 AC 82 ms
15,064 KB
testcase_04 AC 79 ms
15,136 KB
testcase_05 AC 77 ms
15,168 KB
testcase_06 AC 76 ms
15,096 KB
testcase_07 AC 79 ms
15,092 KB
testcase_08 AC 78 ms
15,140 KB
testcase_09 AC 77 ms
15,136 KB
testcase_10 AC 79 ms
15,140 KB
testcase_11 AC 80 ms
15,000 KB
testcase_12 AC 81 ms
15,040 KB
testcase_13 AC 81 ms
15,128 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