結果
問題 | No.1884 Sequence |
ユーザー | masayamatu |
提出日時 | 2022-07-01 21:06:27 |
言語 | C# (.NET 8.0.203) |
結果 |
AC
|
実行時間 | 231 ms / 2,000 ms |
コード長 | 5,708 bytes |
コンパイル時間 | 9,656 ms |
コンパイル使用メモリ | 167,940 KB |
実行使用メモリ | 230,812 KB |
最終ジャッジ日時 | 2024-11-26 03:14:48 |
合計ジャッジ時間 | 17,077 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 64 ms
30,848 KB |
testcase_01 | AC | 64 ms
30,976 KB |
testcase_02 | AC | 63 ms
30,720 KB |
testcase_03 | AC | 60 ms
30,208 KB |
testcase_04 | AC | 63 ms
30,720 KB |
testcase_05 | AC | 64 ms
30,848 KB |
testcase_06 | AC | 65 ms
30,848 KB |
testcase_07 | AC | 67 ms
30,976 KB |
testcase_08 | AC | 64 ms
30,848 KB |
testcase_09 | AC | 64 ms
30,848 KB |
testcase_10 | AC | 230 ms
82,048 KB |
testcase_11 | AC | 229 ms
82,048 KB |
testcase_12 | AC | 99 ms
42,624 KB |
testcase_13 | AC | 99 ms
43,392 KB |
testcase_14 | AC | 99 ms
43,136 KB |
testcase_15 | AC | 167 ms
58,368 KB |
testcase_16 | AC | 231 ms
82,176 KB |
testcase_17 | AC | 130 ms
55,680 KB |
testcase_18 | AC | 162 ms
60,160 KB |
testcase_19 | AC | 139 ms
56,320 KB |
testcase_20 | AC | 154 ms
56,704 KB |
testcase_21 | AC | 133 ms
52,864 KB |
testcase_22 | AC | 161 ms
57,472 KB |
testcase_23 | AC | 229 ms
82,048 KB |
testcase_24 | AC | 229 ms
82,176 KB |
testcase_25 | AC | 229 ms
80,896 KB |
testcase_26 | AC | 229 ms
81,920 KB |
testcase_27 | AC | 96 ms
44,416 KB |
testcase_28 | AC | 101 ms
44,800 KB |
testcase_29 | AC | 103 ms
44,544 KB |
testcase_30 | AC | 101 ms
44,800 KB |
testcase_31 | AC | 151 ms
55,936 KB |
testcase_32 | AC | 214 ms
80,384 KB |
testcase_33 | AC | 180 ms
82,176 KB |
testcase_34 | AC | 180 ms
82,140 KB |
testcase_35 | AC | 111 ms
48,000 KB |
testcase_36 | AC | 157 ms
70,784 KB |
testcase_37 | AC | 203 ms
82,048 KB |
testcase_38 | AC | 200 ms
78,848 KB |
testcase_39 | AC | 122 ms
52,096 KB |
testcase_40 | AC | 130 ms
55,540 KB |
testcase_41 | AC | 200 ms
75,392 KB |
testcase_42 | AC | 201 ms
230,812 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (96 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; //using static CompLib.CompLib; //using DataStructure; namespace atcoder { class Program { const int intMax = 1000000000; const long longMax = 2000000000000000000; static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); var A = Console.ReadLine().Split().Select(long.Parse).ToArray(); var list = new List<long>(); int cnt = 0; for (int i = 0; i < N; i++) { if (A[i] > 0) { list.Add(A[i]); } else { cnt++; } } list = list.OrderBy(a => a).ToList(); var diff = new List<long>(); for (int i = 0; i < list.Count - 1; i++) { diff.Add(list[i + 1] - list[i]); } if (diff.Contains(0)) { if (list[0] == list[list.Count - 1]) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } return; } else if (diff.Count == 0) { Console.WriteLine("Yes"); return; } long gcd = diff[0]; for (int i = 1; i < diff.Count; i++) { gcd = MyMath.gcd(gcd, diff[i]); } long need = 0; foreach (var d in diff) { need += (d / gcd) - 1; } if (need <= cnt) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } public static class MyMath { public static bool IsPrime(long n) { for (int i = 2; i <= Math.Sqrt(n); i++) { if (n % i == 0) { return false; } } return true; } public static List<int> GetPrimes(int n) { var primeList = new List<int>(); var prime = new int[n + 1]; for (int i = 2; i <= n; i++) { int temp = i; int id = 2; while (temp <= n) { prime[temp]++; temp = i * id; id++; } } for (int i = 1; i <= n; i++) { if (prime[i] == 1) { primeList.Add(i); } } return primeList; } public static long gcd(long C, long D) { long tempC = C; long tempD = D; long r = tempD % tempC; while (r != 0) { tempD = tempC; tempC = r; r = tempD % tempC; } return tempC; } public static long lcm(long C, long D) { long tempC = C; long tempD = D; long r = tempD % tempC; while (r != 0) { tempD = tempC; tempC = r; r = tempD % tempC; } long lcm = (long)Math.Floor(((decimal)C * D) / tempC); return lcm; } public static long pow(long x, long n, long mod = 100000007) { long ret = 1; while (n > 0) { if ((n & 1) > 0) ret *= x; ret %= mod; x *= x; x %= mod; n = n >> 1; } return ret; } public static long[,] Transpose(long[,] A) { long[,] AT = new long[A.GetLength(1), A.GetLength(0)]; for (int i = 0; i < A.GetLength(1); i++) { for (int j = 0; j < A.GetLength(0); j++) { AT[i, j] = A[j, i]; } } return AT; } public static long[,] MatrixMultiplication(long[,] A, long[,] B, long mod = 1000000007) { long[,] C = new long[A.GetLength(0), B.GetLength(1)]; for (int i = 0; i < A.GetLength(0); i++) { for (int j = 0; j < B.GetLength(1); j++) { for (int k = 0; k < A.GetLength(1); k++) { C[i, j] += A[i, k] * B[k, j]; C[i, j] %= mod; } } } return C; } public static long[,] MathrixPow(long[,] A, long n, long mod = 1000000007) { long[,] P = A; long[,] Q = new long[A.GetLength(0), A.GetLength(1)]; bool flag = false; for (int i = 0; i < 60; i++) { if ((n & ((long)1 << i)) > 0) { if (!flag) { Q = P; flag = true; } else { Q = MatrixMultiplication(Q, P, mod); } } P = MatrixMultiplication(P, P, mod); } return Q; } } }