結果
問題 |
No.3296 81-like number
|
ユーザー |
![]() |
提出日時 | 2025-10-05 14:08:54 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 67 ms / 2,000 ms |
コード長 | 2,315 bytes |
コンパイル時間 | 8,127 ms |
コンパイル使用メモリ | 169,824 KB |
実行使用メモリ | 189,516 KB |
最終ジャッジ日時 | 2025-10-05 14:09:06 |
合計ジャッジ時間 | 10,239 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (114 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using System.Collections.Generic; using System.Linq; class Program { static string InputPattern = "InputX"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("81"); //315 } else if (InputPattern == "Input2") { WillReturn.Add("216"); //858 } else if (InputPattern == "Input3") { WillReturn.Add("10000000000"); //30756925116342 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static long[] GetSplitArr(string pStr) { return (pStr == "" ? new string[0] : pStr.Split(' ')).Select(pX => long.Parse(pX)).ToArray(); } static void Main() { List<string> InputList = GetInputList(); long N = long.Parse( InputList[0]); long Jyougen = 1; for (long I = 1; I * I <= N; I++) { Jyougen = I; } Eratosthenes(Jyougen); long Answer = 0; foreach (long EachSosuu in mSosuuArr) { long CurrVal = EachSosuu * EachSosuu; while (true) { if (CurrVal <= N) { Answer += CurrVal; } else { break; } CurrVal *= EachSosuu; } } Console.WriteLine(Answer); } static long[] mSosuuArr; // エラトステネスの篩 static void Eratosthenes(long pJyougen) { bool[] IsSosuuArr = new bool[pJyougen + 1]; for (int I = 2; I <= IsSosuuArr.GetUpperBound(0); I++) { IsSosuuArr[I] = true; } for (int I = 2; I * I <= IsSosuuArr.GetUpperBound(0); I++) { if (IsSosuuArr[I]) { for (int J = I * 2; J <= IsSosuuArr.GetUpperBound(0); J += I) { IsSosuuArr[J] = false; } } } var SosuuList = new List<long>(); for (int I = 2; I <= IsSosuuArr.GetUpperBound(0); I++) { if (IsSosuuArr[I]) SosuuList.Add(I); } mSosuuArr = SosuuList.ToArray(); } }