結果
問題 | No.1849 Three Times Value |
ユーザー |
![]() |
提出日時 | 2023-08-23 19:59:51 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 759 bytes |
コンパイル時間 | 846 ms |
コンパイル使用メモリ | 109,904 KB |
実行使用メモリ | 27,860 KB |
最終ジャッジ日時 | 2024-12-22 04:09:08 |
合計ジャッジ時間 | 2,533 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 15 WA * 11 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using static System.Math; using System; public class Hello { static void Main() { var s = Console.ReadLine().Trim(); getAns(s); } static void getAns(string s) { var n = s.Length; if (n % 3 != 0) { var w = n / 3; Console.WriteLine(w > 0 ? new string('9', w) : "0"); } else { var w = n / 3; var ws = s.Substring(0, w); var ww = int.Parse(ws); var www = long.Parse(ws + ws + ws); var ww2 = w > 1 ? int.Parse(new string('9', w - 1)) : 0; var ans = (int)Pow(10, w - 1) - ww + 1 + ww2; if (www > long.Parse(s)) ans--; Console.WriteLine(ans); } } }