結果

問題 No.414 衝動
ユーザー 抹茶アイス抹茶アイス
提出日時 2023-08-01 14:35:28
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 68 ms / 1,000 ms
コード長 1,364 bytes
コンパイル時間 7,576 ms
コンパイル使用メモリ 166,920 KB
実行使用メモリ 182,340 KB
最終ジャッジ日時 2024-04-19 13:49:24
合計ジャッジ時間 9,181 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
30,464 KB
testcase_01 AC 48 ms
28,928 KB
testcase_02 AC 46 ms
28,928 KB
testcase_03 AC 64 ms
31,744 KB
testcase_04 AC 56 ms
30,976 KB
testcase_05 AC 68 ms
31,744 KB
testcase_06 AC 62 ms
31,744 KB
testcase_07 AC 49 ms
28,928 KB
testcase_08 AC 66 ms
31,360 KB
testcase_09 AC 66 ms
31,996 KB
testcase_10 AC 49 ms
28,928 KB
testcase_11 AC 47 ms
29,312 KB
testcase_12 AC 47 ms
182,340 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (93 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/

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

namespace yukicoder
{
    public class Program
    {
        public static void Main()
        {
            var n = long.Parse(Console.ReadLine());
            var k = Prime((long)Math.Sqrt(n));
            var c = true;
            foreach(var m in k)
            {
                if (n % m == 0)
                {
                    Console.WriteLine(m + " " + n / m);
                    c = false;
                    break;
                }
            }
            if (c)
            {
                Console.WriteLine(1 + " " + n);
            }
        }
        static List<int> Prime(long n)
        {
            var isPrime = new bool[n + 1];
            var k = new List<int>();
            for (int i = 2; i <= n; i++)
            {
                isPrime[i] = true;
            }

            for (int i = 2; i * i <= n; i++)
            {
                if (isPrime[i])
                {
                    for (int j = i * i; j <= n; j += i)
                    {
                        isPrime[j] = false;
                    }
                }
            }

            for (int i = 2; i <= n; i++)
            {
                if (isPrime[i])
                {
                    k.Add(i);
                }
            }
            return k;
        }
    }
}
0