結果

問題 No.3159 Just Answer 10 Integers!
ユーザー tnakao0123
提出日時 2025-05-24 17:15:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 760 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 45,004 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-24 17:15:56
合計ジャッジ時間 1,425 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:31:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 3159.cc:  No.3159 Just Answer 10 Integers! - yukicoder
 */

#include<cstdio>
#include<cassert>
#include<algorithm>
#include<numeric>

using namespace std;

/* constant */

const int MAX_N = 10;
const int M = 9;
const int ps[M] = { 2, 3, 5, 7, 11, 13, 17, 19, 23 };

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int pm = 1;
  for (int i = 0; i < M; i++) pm *= ps[i];
  
  for (int i = 0; i < M; i++) as[i] = pm / ps[i];
  as[M] = pm;
  
  for (int i = 0; i < n; i++)
    printf("%d%c", as[i], (i + 1 < n) ? ' ' : '\n');
  
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      assert(lcm(as[i], as[j]) == pm);
  
  return 0;
}
0