結果
問題 |
No.634 硬貨の枚数1
|
ユーザー |
![]() |
提出日時 | 2018-09-09 17:57:27 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 854 bytes |
コンパイル時間 | 850 ms |
コンパイル使用メモリ | 110,632 KB |
実行使用メモリ | 28,008 KB |
最終ジャッジ日時 | 2024-12-23 17:10:05 |
合計ジャッジ時間 | 4,744 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 66 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; public class Hello { public static void Main() { var c = getC(); var n = int.Parse(Console.ReadLine().Trim()); var ans = 0; while (n > 0) { var a = getP(c, n); if (c[a] ==n) { ans++; break; } ans += n / c[a - 1]; n -= (n / c[a - 1]) * c[a - 1]; } Console.WriteLine(ans); } public static int[] getC() { var c = new int[4471]; for (int i = 1; i <= 4471; i++) c[ i -1] = i * (i + 1) / 2; return c; } public static int getP (int[] c , int n) { var ng = 0; var ok = c.Length - 1; while (ok - ng > 1) { var mid = ng + (ok -ng) / 2; if (c[mid] >= n) ok = mid; else ng = mid; } return ok; } }