結果
問題 |
No.375 立方体のN等分 (1)
|
ユーザー |
![]() |
提出日時 | 2016-06-04 22:55:31 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 950 bytes |
コンパイル時間 | 885 ms |
コンパイル使用メモリ | 111,988 KB |
実行使用メモリ | 718,724 KB |
最終ジャッジ日時 | 2024-10-08 09:04:02 |
合計ジャッジ時間 | 7,676 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 3 RE * 1 MLE * 1 -- * 27 |
コンパイルメッセージ
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; namespace No375{ public class Program{ public static void Main(string[] args){ var N = int.Parse(Console.ReadLine()); var input = N; var rl = new List<int>(); if(input > 1){ var nl = Enumerable.Range(2, input - 1).ToList(); var sqrt = (int)Math.Sqrt(input); while(nl[0] <= sqrt){ var prime = nl[0]; rl.Add(prime); nl.RemoveAll(value => value % prime == 0); } rl.AddRange(nl); } var res = 0; foreach(var i in rl){ while(N % i == 0){ N /= i; res += i - 1; } } res += N - 1; Console.WriteLine("{0} {1}", res, input - 1); } } }