結果

問題 No.398 ハーフパイプ(2)
ユーザー nebukuro09nebukuro09
提出日時 2017-03-09 10:42:36
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 1,743 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 104,160 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-03 01:46:39
合計ジャッジ時間 2,301 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 49 ms
4,380 KB
testcase_03 AC 50 ms
4,380 KB
testcase_04 AC 50 ms
4,380 KB
testcase_05 AC 8 ms
4,380 KB
testcase_06 AC 6 ms
4,384 KB
testcase_07 AC 25 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 14 ms
4,380 KB
testcase_10 AC 11 ms
4,384 KB
testcase_11 AC 7 ms
4,388 KB
testcase_12 AC 28 ms
4,376 KB
testcase_13 AC 27 ms
4,380 KB
testcase_14 AC 31 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 26 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;
     
void main() {
    immutable long MAX = 100;
    
    auto N = readln.chomp.replace(".", "").to!long;
    N /= 25;

    long[] f = [1, 1, 2, 6, 24, 120, 720];
    long ans = 0;
    long tmp;
    
    foreach (a; 0..MAX+1) {
        foreach (b; a..MAX+1) {
            foreach (c; b..MAX+1) {
                auto d = N - a - b - c;
                if (d < c || d > MAX) continue;
                long[long] count;
                count[a] += 1;
                count[b] += 1;
                count[c] += 1;
                count[d] += 1;
                
                // a, a, b, c, d, d
                tmp = f[6];
                count[a] += 1;
                count[d] += 1;
                foreach (i; count.values) tmp /= f[i.to!int];
                count[a] -= 1;
                count[d] -= 1;
                ans += tmp;

                // a未満, a, b, c, d, d
                tmp = f[6];
                count[d] += 1;
                foreach (i; count.values) tmp /= f[i.to!int];
                count[d] -= 1;
                ans += tmp * a;

                // a, a, b, c, d, dより大きい
                tmp = f[6];
                count[a] += 1;
                foreach (i; count.values) tmp /= f[i.to!int];
                count[a] -= 1;
                ans += tmp * (MAX-d);

                // a未満, a, b, c, d, dより大きい
                tmp = f[6];
                foreach (i; count.values) tmp /= f[i.to!int];
                ans += tmp * a * (MAX-d);
            }
        }
    }

    ans.writeln;
}
0