Submission #2292221


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

int main() {
  int N;
  cin >> N;

  if(N == 3) {
    cout << 2 << " " << 5 << " " << 63 << endl;
    return (0);
  }

  random_device rd;
  mt19937 rnd(rd());
  vector< int > v;
  for(int i = 2; i <= 30000; i += 2) {
    v.emplace_back(i);
  }
  for(int i = 3; i <= 30000; i += 3) {
    if(i % 2 == 0) continue;
    v.emplace_back(i);
  }
  auto check = [&]() {
    int sum = 0, gcd = 0;
    for(int i = 0; i < N; i++) sum += v[i];
    for(int i = 0; i < N; i++) {
      if(__gcd(sum, v[i]) == 1) return false;
      gcd = __gcd(gcd, v[i]);
    }
    return gcd == 1;
  };
  while(!check()) {
    shuffle(begin(v), end(v), rnd);
  }
  for(int i = 0; i < N; i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}

Submission Info

Submission Time
Task B - GCD Sequence
User ei13333
Language C++14 (GCC 5.4.1)
Score 600
Code Size 800 Byte
Status
Exec Time 25 ms
Memory 512 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt
All 600 / 600 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt 4 ms 512 KB
02.txt 11 ms 512 KB
03.txt 9 ms 512 KB
04.txt 3 ms 512 KB
05.txt 3 ms 512 KB
06.txt 2 ms 512 KB
07.txt 6 ms 512 KB
08.txt 6 ms 512 KB
09.txt 2 ms 512 KB
10.txt 3 ms 512 KB
11.txt 2 ms 512 KB
12.txt 7 ms 512 KB
13.txt 2 ms 512 KB
14.txt 3 ms 512 KB
15.txt 5 ms 512 KB
16.txt 4 ms 512 KB
17.txt 5 ms 512 KB
18.txt 5 ms 512 KB
19.txt 8 ms 512 KB
20.txt 4 ms 512 KB
21.txt 6 ms 512 KB
22.txt 4 ms 512 KB
23.txt 6 ms 512 KB
24.txt 4 ms 512 KB
25.txt 13 ms 512 KB
26.txt 5 ms 512 KB
27.txt 7 ms 512 KB
28.txt 4 ms 512 KB
29.txt 7 ms 512 KB
30.txt 5 ms 512 KB
31.txt 6 ms 512 KB
32.txt 6 ms 512 KB
33.txt 3 ms 512 KB
34.txt 4 ms 512 KB
35.txt 5 ms 512 KB
36.txt 5 ms 512 KB
37.txt 4 ms 512 KB
38.txt 3 ms 512 KB
s1.txt 1 ms 256 KB
s2.txt 25 ms 512 KB