結果

問題 No.32 貯金箱の憂鬱
ユーザー intercept6intercept6
提出日時 2020-08-06 14:21:55
言語 TypeScript
(5.4.3)
結果
AC  
実行時間 77 ms / 5,000 ms
コード長 1,064 bytes
コンパイル時間 8,041 ms
コンパイル使用メモリ 254,308 KB
実行使用メモリ 42,492 KB
最終ジャッジ日時 2023-09-30 13:58:29
合計ジャッジ時間 9,625 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
42,440 KB
testcase_01 AC 76 ms
42,464 KB
testcase_02 AC 76 ms
42,284 KB
testcase_03 AC 76 ms
42,336 KB
testcase_04 AC 75 ms
42,492 KB
testcase_05 AC 76 ms
42,488 KB
testcase_06 AC 77 ms
42,420 KB
testcase_07 AC 76 ms
42,248 KB
testcase_08 AC 76 ms
42,240 KB
testcase_09 AC 76 ms
42,420 KB
testcase_10 AC 76 ms
42,248 KB
testcase_11 AC 76 ms
42,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import { readFileSync } from 'fs';

const getQuotientAndRemainder = ({
  dividend,
  divisor,
}: {
  dividend: number;
  divisor: number;
}): { quotient: number; remainder: number } => {
  return {
    quotient: Math.floor(dividend / divisor),
    remainder: dividend % divisor,
  };
};

function Main(input: string) {
  const data = input.split('\n');

  const beforeHundred = parseInt(data[0]);
  const beforeQuoter = parseInt(data[1]);
  const beforeOne = parseInt(data[2]);

  const sum = beforeOne + beforeQuoter * 25 + beforeHundred * 100;

  const { quotient: afterThousand } = getQuotientAndRemainder({
    dividend: sum,
    divisor: 1000,
  });
  const { quotient: afterHundred } = getQuotientAndRemainder({
    dividend: sum - afterThousand * 1000,
    divisor: 100,
  });
  const {
    quotient: afterQuoter,
    remainder: afterOne,
  } = getQuotientAndRemainder({
    dividend: sum - afterThousand * 1000 - afterHundred * 100,
    divisor: 25,
  });

  console.log(afterHundred + afterQuoter + afterOne);
}

Main(readFileSync('/dev/stdin', 'utf8'));
0