結果

問題 No.339 何人が回答したのか
ユーザー Maeda
提出日時 2025-04-09 15:08:15
言語 C#
(.NET 8.0.404)
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 1,982 bytes
コンパイル時間 8,529 ms
コンパイル使用メモリ 171,668 KB
実行使用メモリ 189,496 KB
最終ジャッジ日時 2025-04-09 15:08:30
合計ジャッジ時間 13,280 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (117 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using Microsoft.SqlServer.Server;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data.Odbc;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;

namespace yukicoderTest
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());  
            int[] parsentList = new int[n];
            List<int> count = new List<int>();
            for (int i = 0; i < n; i++)
            {
                parsentList[i] = int.Parse(Console.ReadLine());
                int result = SeachCommonDivisor(parsentList[i]);
                if (!count.Contains(result)) { 
                    count.Add(result);
                }
            }
            count.Sort();
            count.Reverse();
            int answer = GreatestCommonDivisor(parsentList, count);
            Console.WriteLine(100/answer);
        }

        private static int GreatestCommonDivisor(int[] parsentList, List<int> count)
        {
            int select = 1;
            for(int i = 0; i < count.Count; i++)
            {
                bool okFlg = true;
                for(int j = 0; j < parsentList.Length; j++)
                {
                    if (parsentList[j] % count[i] != 0)
                    {
                        okFlg = false;
                        break;
                    }

                }
                if (okFlg)
                {
                    select = count[i];
                    break;
                }
            }
            return select;
        }

        private static int SeachCommonDivisor(int v)
        {
            int numA = 100;
            int numB = v;
            while(numA % numB  != 0)
            {
                int numC = numA % numB;
                numA = numB;
                numB = numC;
            }
            return numB;
        }
    }
}


0