結果

問題 No.604 誕生日のお小遣い
ユーザー jp_stejp_ste
提出日時 2020-05-03 16:43:42
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 69 ms / 1,000 ms
コード長 2,286 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 39,296 KB
最終ジャッジ日時 2024-05-01 14:43:28
合計ジャッジ時間 4,726 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
39,168 KB
testcase_01 AC 65 ms
39,040 KB
testcase_02 AC 65 ms
39,040 KB
testcase_03 AC 67 ms
39,040 KB
testcase_04 AC 65 ms
38,912 KB
testcase_05 AC 66 ms
38,912 KB
testcase_06 AC 64 ms
39,040 KB
testcase_07 AC 66 ms
38,912 KB
testcase_08 AC 64 ms
38,912 KB
testcase_09 AC 66 ms
39,168 KB
testcase_10 AC 65 ms
39,040 KB
testcase_11 AC 67 ms
39,040 KB
testcase_12 AC 67 ms
39,296 KB
testcase_13 AC 66 ms
39,168 KB
testcase_14 AC 66 ms
39,296 KB
testcase_15 AC 69 ms
39,296 KB
testcase_16 AC 66 ms
39,040 KB
testcase_17 AC 65 ms
39,168 KB
testcase_18 AC 66 ms
39,040 KB
testcase_19 AC 66 ms
39,168 KB
testcase_20 AC 67 ms
39,040 KB
testcase_21 AC 67 ms
39,168 KB
testcase_22 AC 66 ms
38,912 KB
testcase_23 AC 65 ms
39,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function main(input) {
  solve(...getBigIntegers(input));
}

function solve(A, B, C) {
  let l = 1n;
  let r = BigInt(10e18);
  let count = 64;
  while(count-- > 0) {
    let X = (l + r) / 2n;
    let S = (X/A)*B + (X-X/A);
    if(S >= C) {
      r = X;
    } else {
      l = X;
    }
  }
  console.log(r.toString());
}

//-- functions ------------------------------------

function getIntegers(lines) {
  return lines.shift().split(" ").map(function(e) {
    return Number(e);
  });
}

function getBigIntegers(lines) {
  return lines.shift().split(" ").map(function(e) {
    return BigInt(e);
  });
}

function getStrings(lines) {
  return lines.shift().split(" ");
}

function twoDimenArrayByValue(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;
}

function twoDimenArrayByStrings(h, strings) {
  const list = new Array(h);
  for(let i=0; i<h; i++) {
    list[i] = strings.shift().split("");
  }
  return list;
}

function distance(x1, y1, x2, y2) {
  return Math.sqrt((x2-x1) * (x2-x1) + (y2-y1) * (y2-y1));
}

function gcd(a, b) {
  return b === 0 ? a : gcd(b, a % b);
}

//-- Array -------------------------------------------

Array.prototype.deepCopy = function(list) {
  let retList = [];
  for(let i=0; i<list.length; i++) {
    retList[i] = list[i].constructor == Array ? Array.from(list[i]) : list[i];
  }
  return retList;
};

Array.prototype.out = function() {
  let outList = [];
  if(this[0].constructor == Array) {
    for(let i=0; i<this.length; i++) {
      outList.push(this[i].oneLineString());
    } 
  } else {
    outList.push(this.oneLineString());
  }
  console.log(outList.join("\n") + "\n");
};

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").trim().split("\n"));
0