Contest Duration: ~ (local time) (100 minutes) Back to Home

Submission #3155909

Source Code Expand

Copy
```#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

template<class T>
T GCD(T a, T b) {
T c = max(a, b);
T d = min(a, b);
while (c%d != 0) {
T t = d;
d = c % d;
c = t;
}
return d;
}

int main() {
int n, x;
cin >> n >> x;
int a, b, t;
rep(i, 0, n) {
if (i == 0) {
cin >> a;
a = abs(a - x);
t = a;
continue;
}
if (i == 1) {
cin >> b;
b = abs(b - x);
t = GCD(a, b);
continue;
}
int c;
cin >> c;
c = abs(c - x);
t = GCD(t, c);
}
cout << t << endl;
}
```

Submission Info

Submission Time 2018-09-08 21:22:16+0900 C - Skip taku0728 C++ (Clang 3.8.0) 300 1804 Byte AC 112 ms 888 KB

Compile Error

```./Main.cpp:25:13: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using pii = pair<int, int>;
^
./Main.cpp:26:13: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using pss = pair<string, string>;
^
./Main.cpp:27:12: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using vi = vector<int>;
^
./Main.cpp:28:13: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using vvi = vector<vi>;
^
./Main.cpp:29:14: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using vvvi = vector<vvi>;
^
./Main.cpp:30:12: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using vd = vector<double>;
^
./Main.cpp:31:13: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using vvd = vector<vd>;
^
./Main.cpp:32:12: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using vs = vector<string>;
...```

Judge Result

Set Name Score / Max Score Test Cases
All 300 / 300 hand_1, large_1, large_2, large_3, large_4, large_5, large_6, large_7, large_8, max_1, max_2, max_3, min_1, min_2, sample_01, sample_02, sample_03, small_1, small_2, small_3, small_4, small_5
Sample 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
hand_1 7 ms 888 KB
large_1 18 ms 256 KB
large_2 25 ms 256 KB
large_3 20 ms 256 KB
large_4 1 ms 256 KB
large_5 1 ms 256 KB
large_6 1 ms 256 KB
large_7 2 ms 384 KB
large_8 1 ms 256 KB
max_1 111 ms 256 KB
max_2 111 ms 256 KB
max_3 112 ms 256 KB
min_1 1 ms 256 KB
min_2 1 ms 256 KB
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB
sample_03 1 ms 256 KB
small_1 1 ms 256 KB
small_2 1 ms 256 KB
small_3 1 ms 256 KB
small_4 1 ms 256 KB
small_5 1 ms 256 KB