結果

問題 No.332 数列をプレゼントに
ユーザー 紙ぺーぱー
提出日時 2015-12-25 01:12:44
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,824 bytes
コンパイル時間 3,684 ms
コンパイル使用メモリ 111,740 KB
実行使用メモリ 29,516 KB
最終ジャッジ日時 2024-09-18 23:31:18
合計ジャッジ時間 13,047 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 5
other WA * 42
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Diagnostics;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;

namespace Program
{

    public class Solver
    {
        public void Solve()
        {
            var s = Console.ReadLine().Split(' ');
            var n = int.Parse(s[0]).Validate(x => 1 <= x && x <= 100);
            var X = long.Parse(s[1]).Validate(x => 1 <= x && x <= 1000000000000);
            var a = Console.ReadLine().Split(' ').Validate(x => x.Length == n).Select(int.Parse).ToArray().ValidateArray(x => 1 <= x && x <= 1000000000);
            var dotsum = a.Aggregate(BigInteger.One, (x, y) => x * (BigInteger)y).Validate(x => x <= BigInteger.Pow(10, 100));
        }

        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}

#region main
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
    }
}
#endregion

static public class Validator
{
    static public T Validate<T>(this T input, Func<T, bool> f)
    {
        if (!f(input))
            throw new Exception("invalid input");
        return input;
    }
    static public T[] ValidateArray<T>(this T[] input, Func<T, bool> f)
    {
        foreach (var x in input)
            if (!f(x))
                throw new Exception("invalid input");
        return input;
    }
}
0