Submission #62042427


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve() {
int n;
cin >> n;
vector <int> a (n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
auto reduce = [&] (int x, int y) -> array <int, 2> {
while (__gcd(x, y) != 1) {
int g = __gcd(x, y);
x /= g;
y /= g;
}
return {x, y};
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

void solve() {
  int n;
  cin >> n;

  vector <int> a (n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  auto reduce = [&] (int x, int y) -> array <int, 2> {
    while (__gcd(x, y) != 1) {
      int g = __gcd(x, y);
      x /= g;
      y /= g;
    }
    return {x, y};
  };

  array <int, 2> r = reduce(a[0], a[1]);
  for (int i = 0; i < n - 1; ++i) {
    if (reduce(a[i], a[i + 1]) != r) {
      cout << "No" << '\n';
      return;
    }
  }

  cout << "Yes" << '\n';
}

int main() {
  ios_base::sync_with_stdio(0);cin.tie(0);
  int tests = 1;
  // cin >> tests;
  for (int test = 0; test < tests; ++test) {
    solve();
  }
}

Submission Info

Submission Time
Task B - Geometric Sequence
User coleworld223
Language C++ 20 (gcc 12.2)
Score 200
Code Size 749 Byte
Status AC
Exec Time 1 ms
Memory 3608 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 30
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3428 KB
example_01.txt AC 1 ms 3484 KB
example_02.txt AC 1 ms 3488 KB
hand_00.txt AC 1 ms 3428 KB
hand_01.txt AC 1 ms 3416 KB
hand_02.txt AC 1 ms 3608 KB
hand_03.txt AC 1 ms 3524 KB
hand_04.txt AC 1 ms 3364 KB
hand_05.txt AC 1 ms 3472 KB
hand_06.txt AC 1 ms 3488 KB
hand_07.txt AC 1 ms 3384 KB
hand_08.txt AC 1 ms 3368 KB
hand_09.txt AC 1 ms 3440 KB
hand_10.txt AC 1 ms 3424 KB
hand_11.txt AC 1 ms 3472 KB
random_00.txt AC 1 ms 3476 KB
random_01.txt AC 1 ms 3516 KB
random_02.txt AC 1 ms 3524 KB
random_03.txt AC 1 ms 3476 KB
random_04.txt AC 1 ms 3484 KB
random_05.txt AC 1 ms 3492 KB
random_06.txt AC 1 ms 3520 KB
random_07.txt AC 1 ms 3532 KB
random_08.txt AC 1 ms 3608 KB
random_09.txt AC 1 ms 3432 KB
random_10.txt AC 1 ms 3416 KB
random_11.txt AC 1 ms 3604 KB
random_12.txt AC 1 ms 3436 KB
random_13.txt AC 1 ms 3532 KB
random_14.txt AC 1 ms 3488 KB


2025-03-05 (Wed)
20:46:25 +00:00