結果
問題 |
No.375 立方体のN等分 (1)
|
ユーザー |
![]() |
提出日時 | 2016-06-04 23:09:06 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 979 bytes |
コンパイル時間 | 1,677 ms |
コンパイル使用メモリ | 112,460 KB |
実行使用メモリ | 27,596 KB |
最終ジャッジ日時 | 2024-10-08 09:17:55 |
合計ジャッジ時間 | 4,156 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 WA * 19 RE * 1 |
コンパイルメッセージ
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>(); if(input > 1){ var nl = Enumerable.Range(2, (int)Math.Sqrt(input)).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); } var res = 0L; foreach(var i in rl){ while(N % i == 0){ N /= i; res += i - 1; } } res += N - 1; Console.WriteLine("{0} {1}", res, input - 1); } } }