結果

問題 No.381 名声値を稼ごう Extra
ユーザー keymoonkeymoon
提出日時 2021-04-03 01:40:47
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 860 bytes
コンパイル時間 2,669 ms
コンパイル使用メモリ 105,548 KB
実行使用メモリ 27,240 KB
最終ジャッジ日時 2023-08-25 16:09:48
合計ジャッジ時間 3,007 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
23,728 KB
testcase_01 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;
using System.Numerics;

public static class P
{
    public static void Main()
    {
        int digCount = 19;
        BigInteger digit = BigInteger.Pow(10, digCount);
        string ns = Console.ReadLine();
        ns = ns.PadLeft((ns.Length + digCount - 1) / digCount * digCount, '0');
        BigInteger res = 0;
        BigInteger dig = 1;
        for (int i = 0; i < ns.Length; i += digCount)
        {
            var str = ns.Substring(ns.Length - digCount - i, digCount);
            res += dig * long.Parse(str);
            dig *= digit;
        }
        Console.WriteLine(res.ToByteArray().Sum(x => PopCount(x)));
    }

    static int PopCount(int n) //byte
    {
        n = n - ((n >> 1) & 0b01010101);
        n = (n & 0b00110011) + ((n >> 2) & 0b00110011);
        return ((n * 0b00010001) >> 4) & 15;
    }
}
0