結果

問題 No.128 お年玉(1)
ユーザー megane_anko
提出日時 2021-02-14 12:03:10
言語 TypeScript
(5.7.2)
結果
AC  
実行時間 66 ms / 5,000 ms
コード長 666 bytes
コンパイル時間 8,188 ms
コンパイル使用メモリ 229,036 KB
実行使用メモリ 39,424 KB
最終ジャッジ日時 2024-12-31 16:25:24
合計ジャッジ時間 10,655 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import * as fs from 'fs';
const input = fs.readFileSync('/dev/stdin', 'utf8');

const arr = input.split(/[ \n]/);
let N = parseInt(arr[0]);
let M = parseInt(arr[1]);
//何円あげられるか
let result = N / M;
//1000円単位でいくらあげられるか
let answer = 0;

if (result % 1000 === 0) {
    //resultがそのままあげられる金額になる
    answer = result;
} else {
    //resultの中で1000円を何枚あげられるか計算して、1000円未満の端数を消す
    Math.floor(result / 1000);
    //求めた枚数に1000円をかけて、あげる金額にする
    answer = 1000 * Math.floor(result / 1000);
}
console.log(answer);
0