結果
問題 |
No.375 立方体のN等分 (1)
|
ユーザー |
![]() |
提出日時 | 2016-06-04 23:12:00 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,009 bytes |
コンパイル時間 | 913 ms |
コンパイル使用メモリ | 116,548 KB |
実行使用メモリ | 27,480 KB |
最終ジャッジ日時 | 2024-10-08 09:21:57 |
合計ジャッジ時間 | 3,717 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 WA * 19 |
コンパイルメッセージ
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 = long.Parse(Console.ReadLine()); var input = N; var rl = new List<int>(); var res = 0L; if(input > 1){ var nl = Enumerable.Range(2, (int)Math.Sqrt(input) + 1).ToList(); var sqrt = (int)Math.Sqrt(Math.Sqrt(input)) + 1; while(nl[0] <= sqrt){ var prime = nl[0]; rl.Add(prime); nl.RemoveAll(value => value % prime == 0); } rl.AddRange(nl); foreach(var i in rl) { while(N % i == 0) { N /= i; res += i - 1; } } } res += N - 1; Console.WriteLine("{0} {1}", res, input - 1); } } }