結果
| 問題 | No.888 約数の総和 |
| コンテスト | |
| ユーザー |
tomomo2b2
|
| 提出日時 | 2019-10-11 17:57:07 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,149 bytes |
| コンパイル時間 | 2,971 ms |
| コンパイル使用メモリ | 112,516 KB |
| 実行使用メモリ | 28,412 KB |
| 最終ジャッジ日時 | 2024-11-24 23:48:51 |
| 合計ジャッジ時間 | 4,969 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 4 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
class MyClass
{
public static void Solve()
{
var N = long.Parse(Console.ReadLine());
var exp = new Dictionary<long, long>();
long sum = 1;
if (N % 2 == 0)
{
exp.Add(2, 0);
while (N % 2 == 0)
{
N /= 2;
exp[2]++;
}
}
for (long p = 3; p * p <= N; p += 2)
{
if (N % p == 0)
{
exp.Add(p, 0);
while (N % p == 0)
{
N /= p;
exp[p]++;
}
}
}
if (N != 1)
{
exp.Add(N, 1);
}
foreach (var p in exp.Keys)
{
sum *= ((long)Math.Pow(p, exp[p] + 1) - 1) / (p - 1);
}
Console.WriteLine(sum);
}
public static void Main()
{
var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
}
tomomo2b2