結果

問題 No.375 立方体のN等分 (1)
ユーザー noriocnorioc
提出日時 2016-06-05 13:34:17
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,918 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 111,832 KB
実行使用メモリ 27,044 KB
最終ジャッジ日時 2024-04-17 04:46:46
合計ジャッジ時間 2,833 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 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.Collections.Generic;
using System.Linq;

class Program {
    static string ReadLine() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    static void Test() {
        // m^n が 65535 を超える
        for (int i = 2; ; i++) { // i 種類の文字を使って p 文字の文字列を作る
            int p = 1;
            while (Math.Pow(i, p+1) <= 63353) {
                p++;
            }

            if (i <= p) {
                Console.WriteLine("{0}^{1} = {2}", i, p, Math.Pow(i, p));
            }

            if (p == 1) break;
        }
    }

    static int RunLength(int[] xs) {
        int len = 0;
        int x = xs[0];
        int n = 1;
        for (int i = 1; i < xs.Length; i++) {
            if (x == xs[i]) {
                n++;
            }
            else {
                len += 1 + n.ToString().Length;
                n = 1;
            }
        }
        len += 1 + n.ToString().Length;
        return len;
    }

    static int Calc_1(int p, int[] xs, int m) {
        if (p == xs.Length) {
            if (xs.Length > RunLength(xs)) return 1;
            return 0;
        }

        int ret = 0;
        for (int i = 0; i < m; i++) {
            xs[p] = i;
            ret += Calc_1(p+1, xs, m);
        }
        return ret;
    }

    static int Calc(int m, int n) {
        var xs = new int[n];
        return Calc_1(0, xs, m);
    }

    static void Main() {
        // Test();

        var mn = ReadLine().Split(new[] { ',' }).Select(int.Parse).ToArray();
        int m = mn[0], n = mn[1];

        int ans = Calc(m, n);
        Console.WriteLine(ans);
    }
}

/*

Input   Output
2,5     10
3,10    2505
4,7     616
2,16    19898
8,5     232

*/
0