結果

問題 No.634 硬貨の枚数1
ユーザー te-shte-sh
提出日時 2018-01-23 14:18:11
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 728 bytes
コンパイル時間 569 ms
コンパイル使用メモリ 83,348 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2023-09-03 18:13:23
合計ジャッジ時間 3,629 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 12 ms
12,096 KB
testcase_16 AC 6 ms
6,144 KB
testcase_17 AC 8 ms
7,452 KB
testcase_18 AC 6 ms
6,108 KB
testcase_19 AC 4 ms
10,284 KB
testcase_20 AC 6 ms
12,564 KB
testcase_21 AC 13 ms
13,572 KB
testcase_22 AC 11 ms
11,284 KB
testcase_23 AC 6 ms
5,888 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 4 ms
5,400 KB
testcase_36 AC 9 ms
8,784 KB
testcase_37 AC 7 ms
6,464 KB
testcase_38 AC 3 ms
4,380 KB
testcase_39 AC 11 ms
12,344 KB
testcase_40 AC 8 ms
8,736 KB
testcase_41 AC 7 ms
8,012 KB
testcase_42 AC 10 ms
10,988 KB
testcase_43 AC 5 ms
5,616 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 6 ms
12,896 KB
testcase_48 WA -
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 13 ms
12,604 KB
testcase_51 AC 3 ms
4,380 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 13 ms
13,240 KB
testcase_56 AC 13 ms
12,612 KB
testcase_57 AC 13 ms
12,896 KB
testcase_58 AC 13 ms
12,604 KB
testcase_59 AC 13 ms
12,324 KB
testcase_60 AC 13 ms
12,600 KB
testcase_61 AC 12 ms
12,304 KB
testcase_62 AC 13 ms
12,568 KB
testcase_63 AC 14 ms
12,840 KB
testcase_64 AC 13 ms
13,328 KB
testcase_65 AC 12 ms
12,564 KB
testcase_66 AC 13 ms
13,240 KB
testcase_67 AC 13 ms
12,564 KB
testcase_68 AC 13 ms
12,612 KB
testcase_69 AC 12 ms
12,872 KB
testcase_70 AC 13 ms
13,824 KB
testcase_71 AC 12 ms
12,048 KB
testcase_72 AC 12 ms
12,860 KB
testcase_73 AC 13 ms
13,068 KB
testcase_74 AC 12 ms
12,612 KB
testcase_75 AC 13 ms
12,772 KB
testcase_76 AC 2 ms
4,376 KB
testcase_77 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
T[] readArray(T)(size_t n){auto a=new T[](n),r=readln.splitter;foreach(ref v;a){v=r.front.to!T;r.popFront;}return a;}
T[] readArrayM(T)(size_t n){auto a=new T[](n);foreach(ref v;a)v=readln.chomp.to!T;return a;}

void main()
{
  int n; readV(n);

  int[] t;
  foreach (k; 0..n) {
    auto ti = k*(k+1)/2;
    if (ti > n) break;
    t ~= ti;
  }

  auto b = new bool[](n+1);
  foreach (ti; t) b[ti] = true;

  if (b[n]) {
    writeln(1);
    return;
  }

  foreach (i; 1..n+1)
    if (b[i] && b[n-i]) {
      writeln(2);
      return;
    }

  writeln(3);
}
0