結果

問題 No.1450 nahco314's First Problem
ユーザー tatt61880
提出日時 2021-04-03 13:25:31
言語 Kuin
(KuinC++ v.2021.9.17)
結果
WA  
実行時間 -
コード長 398 bytes
コンパイル時間 7,474 ms
コンパイル使用メモリ 146,460 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-08 14:27:05
合計ジャッジ時間 3,990 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var x: int :: cui@inputInt()
	var ans: int :: -1
	for n([0, x - 100].max(), x + 100)
		if((n $ bit64).xor(hammingWeight(n)) = x $ bit64)
			do ans :: n
			break n
		end if
	end for
	do cui@print("\{ans}\n")
	
	func hammingWeight(n: int): bit64
		var res: int :: 0
		while(n <> 0)
			if(n % 2 = 1)
				do res :+ 1
			end if
			do n :/ 2
		end while
		ret res $ bit64
	end func
end func
0