結果

問題 No.2609 Decreasing GCDs
ユーザー Maksym ShcherbanMaksym Shcherban
提出日時 2024-01-19 22:26:02
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 103 ms / 1,000 ms
コード長 694 bytes
コンパイル時間 43 ms
コンパイル使用メモリ 6,548 KB
実行使用メモリ 41,676 KB
最終ジャッジ日時 2024-01-19 22:26:07
合計ジャッジ時間 4,418 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
41,676 KB
testcase_01 AC 84 ms
41,676 KB
testcase_02 AC 85 ms
41,676 KB
testcase_03 AC 82 ms
41,676 KB
testcase_04 AC 83 ms
41,676 KB
testcase_05 AC 84 ms
41,676 KB
testcase_06 AC 84 ms
41,676 KB
testcase_07 AC 84 ms
41,676 KB
testcase_08 AC 82 ms
41,676 KB
testcase_09 AC 83 ms
41,676 KB
testcase_10 AC 82 ms
41,676 KB
testcase_11 AC 82 ms
41,676 KB
testcase_12 AC 81 ms
41,676 KB
testcase_13 AC 79 ms
41,676 KB
testcase_14 AC 81 ms
41,676 KB
testcase_15 AC 81 ms
41,676 KB
testcase_16 AC 85 ms
41,676 KB
testcase_17 AC 82 ms
41,676 KB
testcase_18 AC 82 ms
41,676 KB
testcase_19 AC 85 ms
41,676 KB
testcase_20 AC 82 ms
41,676 KB
testcase_21 AC 78 ms
41,676 KB
testcase_22 AC 103 ms
41,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const n = +require("fs").readFileSync("/dev/stdin", "utf8");

const primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89].reverse();
const mul = [1, 1, 2, 3, 4, 5, 6, 7, 9, 13, 17, 20, 27, 37, 49, 67, 110, 1, 1, 1, 1, 1, 1, 1, 1, 1];
const gcd = (a, b) => {
  if (!b) return a;
  return gcd(b, a % b);
}

const result = [primes[0]];
for (let i = 1; i < 25; i++) {
  let next = primes[i - 1];
  if (i < primes.length) {
    next *= primes[i];
  }
  for (let j = 1; ; j++) {
    if (gcd(j, result[i - 1]) === 1 && next * j > result[i - 1]) {
      next *= j;
      break;
    }
  }
  result.push(next);
}
console.log(result.slice(0, n).join(' '));
0