結果
問題 |
No.1586 Equal Array
|
ユーザー |
![]() |
提出日時 | 2021-07-08 22:25:22 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,985 bytes |
コンパイル時間 | 2,907 ms |
コンパイル使用メモリ | 110,592 KB |
実行使用メモリ | 32,896 KB |
最終ジャッジ日時 | 2024-07-01 12:45:58 |
合計ジャッジ時間 | 4,930 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 6 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; using System.Collections.Generic; using System.Text; namespace Main { class Program { static void Main(string[] args) { int N = ReadInt1(); int[] Ary = ReadIntAry(); int sum = 0; for (int i = 0; i < N; i++) { sum += Ary[i]; } Console.WriteLine((sum % N == 0) ? "Yes" : "No"); } public static int Lcm(int a, int b) { return a * b / Gcd(a, b); } public static int Gcd(int a, int b) { if (a < b) return Gcd(b, a); while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } static void AddValue2Dic(ref Dictionary<string, int> dic, string key, int val) { if (!dic.ContainsKey(key)) dic.Add(key, val); else dic[key] += val; } static void AddValue2Dic(ref Dictionary<int, int> dic, int key, int val) { if (!dic.ContainsKey(key)) dic.Add(key, val); else dic[key] += val; } static long[] ReadLongAry() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse); static long ReadLong1() { return long.Parse(Console.ReadLine()); } static (long, long) ReadLong2() { var x = ReadLongAry(); return (x[0], x[1]); } static (long, long, long) ReadLong3() { var x = ReadLongAry(); return (x[0], x[1], x[2]); } static int[] ReadIntAry() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse); static int ReadInt1() { return int.Parse(Console.ReadLine()); } static (int, int) ReadInt2() { var x = ReadIntAry(); return (x[0], x[1]); } static (int, int, int) ReadInt3() { var x = ReadIntAry(); return (x[0], x[1], x[2]); } static string[] ReadStrAry() => Console.ReadLine().Split(); static string ReadStr1() { return Console.ReadLine(); } static (string, string) ReadStr2() { var x = ReadStrAry(); return (x[0], x[1]); } static (string, string, string) ReadStr3() { var x = ReadStrAry(); return (x[0], x[1], x[2]); } } public static class Combination { public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) { if (k == 1) { foreach (var item in items) yield return new T[] { item }; yield break; } foreach (var item in items) { var leftside = new T[] { item }; var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList(); foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) { yield return leftside.Concat(rightside).ToArray(); } } } } }