結果
問題 |
No.589 Counting Even
|
ユーザー |
![]() |
提出日時 | 2018-01-27 00:49:33 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 1,376 bytes |
コンパイル時間 | 2,671 ms |
コンパイル使用メモリ | 107,776 KB |
実行使用メモリ | 20,536 KB |
最終ジャッジ日時 | 2024-12-28 03:27:46 |
合計ジャッジ時間 | 4,477 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; using System.Collections.Generic; namespace y { class Program { static void Main(string[] args) { var n = long.Parse(Console.ReadLine()); long c = 0; long[] a = { 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647, 4294967295, 8589934591, 17179869183, 34359738367, 68719476735, 137438953471, 274877906943, 549755813887, 1099511627775, 2199023255551, 4398046511103, 8796093022207, 17592186044415, 35184372088831, 70368744177663, 140737488355327, 281474976710655, 562949953421311, 1125899906842623, 2251799813685247, 4503599627370495, 9007199254740991, 18014398509481983, 36028797018963967, 72057594037927935, 144115188075855871, 288230376151711743, 576460752303423487, 1152921504606846975 }; long h = 1; if (n == 1) n = 0; while (n != 0) { var b = a.Where(x => x < n).Max(); if (b - (n - b - 1) == 0)break; c += (b - (n - b - 1)) * h; n = (n - (b - (n - b - 1))) / 2; if (n == 1) break; h *= 2; } Console.WriteLine(c); } } }