結果

問題 No.3045 怪文書
ユーザー AreTrashAreTrash
提出日時 2019-04-01 22:03:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 2,400 bytes
コンパイル時間 3,062 ms
コンパイル使用メモリ 108,872 KB
実行使用メモリ 22,832 KB
最終ジャッジ日時 2023-08-18 01:08:07
合計ジャッジ時間 5,292 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
22,756 KB
testcase_01 AC 57 ms
20,800 KB
testcase_02 AC 57 ms
20,740 KB
testcase_03 AC 57 ms
20,784 KB
testcase_04 AC 58 ms
20,704 KB
testcase_05 AC 57 ms
22,832 KB
testcase_06 AC 57 ms
20,696 KB
testcase_07 AC 59 ms
20,648 KB
testcase_08 AC 57 ms
20,644 KB
testcase_09 AC 57 ms
22,776 KB
testcase_10 AC 57 ms
20,652 KB
testcase_11 AC 57 ms
20,784 KB
testcase_12 AC 57 ms
20,644 KB
testcase_13 AC 56 ms
20,648 KB
testcase_14 AC 57 ms
22,776 KB
testcase_15 AC 56 ms
18,736 KB
testcase_16 AC 57 ms
20,780 KB
testcase_17 AC 57 ms
22,692 KB
testcase_18 AC 57 ms
20,712 KB
testcase_19 AC 57 ms
20,760 KB
testcase_20 AC 56 ms
20,772 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.IO;
using System.Collections.Generic;

namespace No3045
{
    public partial class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(long.Parse);
            var M = ss.Next(long.Parse);

            if (N >= M)
            {
                sw.WriteLine(0);
                return;
            }

            var ans = 1L;

            for (var i = 1; i <= N; i++)
            {
                ans *= i;
                ans %= M;
            }

            sw.WriteLine(ans);
            //---------------------------------
        }
    }

    public class StreamScanner
    {
        static readonly char[] Separator = { ' ' };
        readonly StreamReader streamReader;

        string[] line = new string[0];
        int index = 0;

        public StreamScanner(Stream stream)
        {
            this.streamReader = new StreamReader(stream);
        }

        public string Next()
        {
            return Next(s => s);
        }

        public string[] Next(int x)
        {
            return Next(s => s, x);
        }

        public string[][] Next(int x, int y)
        {
            return Next(s => s, x, y);
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (index < line.Length) return parser(line[index++]);
            index = 0;
            line = streamReader.ReadLine()?.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }

    public partial class Program
    {
        static void Main()
        {
            Excute(Console.OpenStandardInput(), Console.OpenStandardOutput());
        }

        public static void Excute(Stream input, Stream output)
        {
            var ss = new StreamScanner(input);
            var sw = new StreamWriter(output);
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }
}
0