結果

問題 No.294 SuperFizzBuzz
ユーザー AreTrashAreTrash
提出日時 2016-09-30 07:26:39
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 254 ms / 5,000 ms
コード長 1,061 bytes
コンパイル時間 820 ms
コンパイル使用メモリ 113,688 KB
実行使用メモリ 26,084 KB
最終ジャッジ日時 2024-05-01 08:09:03
合計ジャッジ時間 2,929 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
23,908 KB
testcase_01 AC 20 ms
26,072 KB
testcase_02 AC 254 ms
25,960 KB
testcase_03 AC 21 ms
25,824 KB
testcase_04 AC 19 ms
23,856 KB
testcase_05 AC 20 ms
26,084 KB
testcase_06 AC 20 ms
25,960 KB
testcase_07 AC 19 ms
23,856 KB
testcase_08 AC 32 ms
23,788 KB
testcase_09 AC 148 ms
23,780 KB
testcase_10 AC 151 ms
23,908 KB
testcase_11 AC 229 ms
23,988 KB
testcase_12 AC 242 ms
24,176 KB
testcase_13 AC 247 ms
23,656 KB
testcase_14 AC 245 ms
23,784 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace No294{
    public class Program{
        public static void Main(string[] args){
            var N = int.Parse(Console.ReadLine());

            var cnt = 0;
            for(var i = 1; i < 114514810; i++){
                for(var j = 0; j < 1 << i; j++){
                    var pc = Ex.PopCount(j) + 1;
                    if((pc * 5 + (i - pc) * 3) % 3 == 0){
                        cnt++;
                    }
                    if(cnt == N){
                        Console.WriteLine((Convert.ToString(j, 2).PadLeft(i, '0') + 5).Replace('0', '3').Replace('1', '5'));
                        return;
                    }
                }
            }
        }
    }

    public class Ex{
        public static int PopCount(int x){
            //From http://turedure-plog.blogspot.jp/2014/03/popcount.html
            x = x - (x >> 1 & 0x55555555);
            x = (x & 0x33333333) + (x >> 2 & 0x33333333);
            x = x + (x >> 4) & 0x0f0f0f0f;
            x = x * 0x01010101;
            return x >> 24;
        }
    }
}
0