結果

問題 No.414 衝動
ユーザー claw88claw88
提出日時 2016-08-26 23:50:19
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 68 ms / 1,000 ms
コード長 1,548 bytes
コンパイル時間 2,188 ms
コンパイル使用メモリ 105,844 KB
実行使用メモリ 24,388 KB
最終ジャッジ日時 2023-08-09 13:23:33
合計ジャッジ時間 4,070 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
23,484 KB
testcase_01 AC 56 ms
20,724 KB
testcase_02 AC 54 ms
18,772 KB
testcase_03 AC 65 ms
22,216 KB
testcase_04 AC 54 ms
20,900 KB
testcase_05 AC 67 ms
22,180 KB
testcase_06 AC 68 ms
22,132 KB
testcase_07 AC 56 ms
20,672 KB
testcase_08 AC 63 ms
21,320 KB
testcase_09 AC 68 ms
24,388 KB
testcase_10 AC 54 ms
20,620 KB
testcase_11 AC 57 ms
20,684 KB
testcase_12 AC 57 ms
20,884 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yuki414
{
    class Program
    {
        static void Main(string[] args)
        {
            long m = long.Parse(Console.ReadLine());

            if (m % 2 == 0)
            {
                Console.WriteLine(2+" "+m/2);
            }
            else
            {
                int n = (int)Math.Sqrt(m);
                var p = new List<int>();
                eratos(p, n);
                bool flag = true;
                foreach (var item in p)
                {
                    if (m % item == 0)
                    {
                        Console.WriteLine(item+" "+m/item);
                        flag = false;
                        break;
                    }
                }

                if (flag)
                {
                    Console.WriteLine(1+" "+m);
                }
            }
        }
        static void eratos(List<int> Prime, int n)
        {
            var a = new bool[n + 1];
            a[0] = a[1] = true;
            int i;
            for (i = 2; i * i <= n; i++)
            {
                if (!a[i])
                {
                    Prime.Add(i);
                    int j = i << 1;
                    while (j <= n)
                    {
                        a[j] = true;
                        j = j + i;
                    }
                }
            }
            for (; i <= n; i++) if (!a[i]) Prime.Add(i);
        }


    }
}
0