結果
| 問題 | No.51 やる気の問題 | 
| コンテスト | |
| ユーザー |  jp_ste | 
| 提出日時 | 2020-04-26 15:57:26 | 
| 言語 | JavaScript (node v23.5.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 68 ms / 5,000 ms | 
| コード長 | 1,198 bytes | 
| コンパイル時間 | 150 ms | 
| コンパイル使用メモリ | 7,072 KB | 
| 実行使用メモリ | 44,160 KB | 
| 最終ジャッジ日時 | 2024-10-13 01:44:54 | 
| 合計ジャッジ時間 | 2,265 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 | 
ソースコード
function main(input) {
  let [w] = getIntegers(input);
  let [d] = getIntegers(input);
  while(d > 1) {
    w = w - Math.floor(w / (d*d));
    d--;
  }
  console.log(w);
}
//-- functions ------------------------------------
function getIntegers(lines) {
  return lines.shift().split(" ").map(function(e) {
    return Number(e);
  });
}
function getStrings(lines) {
  return lines.shift().split(" ");
}
function twoDimensionalArray(h, w, value) {
  const list = new Array(h);
  for(let i=0; i<h; i++) {
    list[i] = new Array(w).fill().map(function(e) {
      return value.constructor == Array ? Array.from(value) : value;
    });
  }
  return list;
}
//-- Array -------------------------------------------
Array.prototype.pushNoSameValue = function(...values) {
  values.forEach(function(e) {
    if(!this.includes(e)) {
      this.push(e);
    }
  }, this);
};
Array.prototype.sortByIntegers = function() {
  this.sort(function(a, b) {
    return a - b;
  });
};
Array.prototype.oneLineString = function() {
  let str = "";
  this.forEach(function(e, i) {
    if(i > 0) str += " ";
    str += e;
  });
  return str;
};
main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));
            
            
            
        