結果

問題 No.480 合計
コンテスト
ユーザー mk
提出日時 2022-01-10 17:09:03
言語 JavaScript(Node)
(node v26.11.1 + ACL)
コンパイル:
true
実行:
node _filename_ ONLINE_JUDGE
結果
AC  
実行時間 41 ms / 2,000 ms
+ 991µs
コード長 767 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3 ms
コンパイル使用メモリ 7,856 KB
実行使用メモリ 51,136 KB
最終ジャッジ日時 2026-09-22 08:34:53
合計ジャッジ時間 3,045 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

const lineIter = (function* () {
  const stdin = require('fs').readFileSync(process.stdin.fd, 'utf8');
  const lines = stdin.trim().split('\n');
  for (const line of lines) {
    yield line.trim();
  }
})();
const wordIter = (function* () {
  while (true) {
    const { done, value: line } = lineIter.next();
    if (done) {
      break;
    }
    const words = line.split(' ');
    for (const word of words) {
      yield word;
    }
  }
})();
const read = () => wordIter.next().value;

const main = async () => {
  const n = parseInt(read());

  const sum = Array(n)
    .fill()
    .map((_, i) => i + 1)
    .reduce((acc, num) => acc + num, 0);

  console.log(`${sum}`);
};

(async () => {
  try {
    await main();
  } catch (e) {
    console.error(e);
  }
})();
0