結果
| 問題 |
No.1884 Sequence
|
| コンテスト | |
| ユーザー |
kenya_hobb
|
| 提出日時 | 2022-03-26 20:10:44 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,811 bytes |
| コンパイル時間 | 3,477 ms |
| コンパイル使用メモリ | 112,324 KB |
| 実行使用メモリ | 60,672 KB |
| 最終ジャッジ日時 | 2024-10-15 12:21:31 |
| 合計ジャッジ時間 | 10,880 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 WA * 8 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace ConsoleApp1
{
class Program
{
//private static int[] A = new int[200005];//MargeSort用
//private static int[] C = new int[200005];
static void Main(string[] args)
{
long N = long.Parse(Console.ReadLine());
long[] A = Console.ReadLine().Split().Select(long.Parse).ToArray(); //SelectはLinq
bool ok = true;
Array.Sort(A);
Array.Reverse(A);
long kousa = A[0] - A[1];
long need_zero = 0;
for(int i = 1; i < N - 1; i++)
{
if(A[i + 1] != 0 && A[i] != 0)
kousa = GCD(kousa, A[i] - A[i + 1]);
}
for (int i = 0; i < N - 1; i++)
{
if (A[i] - A[i + 1] != kousa && A[i] != 0 && A[i + 1] != 0)
need_zero += (A[i] - A[i + 1]) / kousa;
}
if (need_zero <= A.Count(x => x == 0))
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
static long GCD(long a, long b)//公約数 再起関数にしてみるいつか
{
while (a > 0 && b > 0)
{
if (a > b)
a = a % b;
else
b = b % a;
}
if (a == 0)
return b;
else
return a;
}
static long LCD(long a, long b)
{
return a / GCD(a, b) * b;
}
//static void MargeSort(int l, int r)//A配列とC配列(ソート後)を用意する必要あり
//{
// if (r - l == 1) return;
// int m = (l + r) / 2;
// MargeSort(l, m);
// MargeSort(m, r);
// int c1 = l, c2 = m, cnt = 0;
// while(c1 != m || c2 != r)
// {
// if(c1 == m)
// {
// C[cnt] = A[c2];
// c2++;
// }
// else if(c2 == r)
// {
// C[cnt] = A[c1];
// c1++;
// }
// else
// {
// if (A[c1] <= A[c2])
// {
// C[cnt] = A[c1];
// c1++;
// }
// else
// {
// C[cnt] = A[c2];
// c2++;
// }
// }
// cnt++;
// }
// for(int i = 0; i < cnt; i++)
// {
// A[l + i] = C[i];
// }
//}
}
}
kenya_hobb