結果
| 問題 |
No.219 巨大数の概算
|
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2024-10-10 23:37:09 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 247 ms / 1,500 ms |
| コード長 | 2,153 bytes |
| コンパイル時間 | 948 ms |
| コンパイル使用メモリ | 113,796 KB |
| 実行使用メモリ | 35,524 KB |
| 最終ジャッジ日時 | 2024-10-10 23:37:25 |
| 合計ジャッジ時間 | 15,824 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 51 |
コンパイルメッセージ
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;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("2");
WillReturn.Add("2 10");
WillReturn.Add("9 9");
//1 0 3
//3 8 8
//9の9乗は387420489です。これは9桁の数(10の8乗オーダー)であり、
//最上位の数は3、上から2番目の数は8です。
//上から3番目の数は7ですが、切り捨てます。
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
struct ABInfoDef
{
internal int A;
internal int B;
}
static void Main()
{
List<string> InputList = GetInputList();
var ABInfoList = new List<ABInfoDef>();
foreach (string EachStr in InputList.Skip(1)) {
int[] wkArr = EachStr.Split(' ').Select(X => int.Parse(X)).ToArray();
ABInfoList.Add(new ABInfoDef() { A = wkArr[0], B = wkArr[1] });
}
ABInfoList.ForEach(Solve);
}
struct ResultInfoDef
{
internal double X;
internal double Y;
internal double Z;
}
static void Solve(ABInfoDef pABInfo)
{
double Sahen = pABInfo.B * Math.Log10(pABInfo.A);
//丸め誤差が一番小さい値を解とする
var ResultInfoList = new List<ResultInfoDef>();
for (double X = 1; X <= 9; X++) {
for (double Y = 0; Y <= 9; Y++) {
double Z = Sahen - Math.Log10(X + Y / 10);
if (Math.Round(Z) == 0) continue;
ResultInfoList.Add(new ResultInfoDef() { X = X, Y = Y, Z = Z });
}
}
ResultInfoDef Answer =
ResultInfoList.OrderBy(A => Math.Abs(A.Z - Math.Truncate(A.Z))).First();
Console.WriteLine("{0} {1} {2}", Answer.X, Answer.Y, Math.Round(Answer.Z));
}
}
aketijyuuzou