結果
問題 | No.414 衝動 |
ユーザー |
|
提出日時 | 2016-08-26 23:50:19 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 33 ms / 1,000 ms |
コード長 | 1,548 bytes |
コンパイル時間 | 2,554 ms |
コンパイル使用メモリ | 104,832 KB |
実行使用メモリ | 18,944 KB |
最終ジャッジ日時 | 2024-11-15 09:05:11 |
合計ジャッジ時間 | 2,075 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 |
コンパイルメッセージ
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.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);}}}