結果

問題 No.1089 三変数方程式
ユーザー fairy_lettucefairy_lettuce
提出日時 2020-06-24 01:51:06
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 2,575 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 106,972 KB
実行使用メモリ 22,840 KB
最終ジャッジ日時 2023-09-16 20:26:35
合計ジャッジ時間 3,945 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
18,632 KB
testcase_01 AC 54 ms
22,784 KB
testcase_02 AC 55 ms
20,720 KB
testcase_03 AC 55 ms
22,840 KB
testcase_04 AC 52 ms
20,728 KB
testcase_05 AC 53 ms
20,736 KB
testcase_06 AC 54 ms
20,796 KB
testcase_07 AC 54 ms
20,788 KB
testcase_08 AC 54 ms
22,680 KB
testcase_09 AC 53 ms
20,812 KB
testcase_10 AC 53 ms
20,864 KB
testcase_11 AC 55 ms
22,692 KB
testcase_12 AC 53 ms
22,748 KB
testcase_13 AC 52 ms
22,780 KB
testcase_14 AC 54 ms
20,844 KB
testcase_15 AC 54 ms
20,716 KB
testcase_16 AC 53 ms
20,856 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;
using System.Linq;

namespace AtCoder.Contest.B
{
	static class Program
	{
		public static void Solve(Scanner cin)
		{
			long n = cin.ReadInt();
			Console.WriteLine(Calc.nCr(n + 2, 2));
		}

		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);
			var cin = new Scanner();
			Solve(cin);
			Console.Out.Flush();
		}
	}

	public static partial class Calc
	{
		public static long nCr(long n, long r)
		{
			if (n < 0 || r < 0 || r > n) return 0;
			return nPr(n, r) / Factorial(r);
		}

		public static long nPr(long n, long r)
		{
			if (n < 0 || r < 0 || r > n) return 0;
			return FactorialDivision(n, n - r);
		}

		private static long FactorialDivision(long topFactorial, long divisorFactorial)
		{
			long result = 1;
			for (long i = topFactorial; i > divisorFactorial; i--)
			{
				result *= i;
			}
			return result;
		}

		public static long Factorial(long i)
		{
			return i <= 1 ? 1 : i * Factorial(i - 1);
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Read() => ReadString();

		public string ReadString()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return ReadString();
			i = 0;
			return s[i++];
		}

		public string[] ReadStringArray(int N)
		{
			string[] Array = new string[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadString();
			}
			return Array;
		}

		public int ReadInt()
		{
			return int.Parse(ReadString());
		}

		public int[] ReadIntArray(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadInt() + add;
			}
			return Array;
		}

		public long ReadLong()
		{
			return long.Parse(ReadString());
		}

		public long[] ReadLongArray(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadLong() + add;
			}
			return Array;
		}

		public double ReadDouble()
		{
			return double.Parse(ReadString());
		}

		public double[] ReadDoubleArray(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadDouble() + add;
			}
			return Array;
		}

		public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1));

	}
}
0