QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#701850 | #5542. Doubled GCD | MeatInTheMiddle# | WA | 0ms | 3684kb | C++17 | 1022b | 2024-11-02 14:48:50 | 2024-11-02 14:48:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fastio (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL))
typedef long long ll;
typedef long double lld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
const int MAXSIZE = 2000000;
const long long INF = 1e18 + 5;
const double EPSILON = 1e-14;
const ll DIV = 2000003;
const long double pi = 3.14159265358979323846264338327950288419716939937510L;
int n;
int gcd(int a, int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
pair<int, int> arr[200005];
int get(int a)
{
int ret = 0;
while (a % 2 == 0)
ret++, a /= 2;
return ret;
}
int main()
{
fastio;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> arr[i].second;
arr[i].first = get(arr[i].second);
}
sort(arr, arr + n);
int ans = arr[0].second;
for (int i = 1; i < n; i++)
{
ans = 2 * gcd(ans, arr[i].second);
}
cout << ans;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
3 2 4 6
output:
8
result:
ok single line: '8'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
3 3 5 7
output:
2
result:
ok single line: '2'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3660kb
input:
4 9 9 9 9
output:
18
result:
wrong answer 1st lines differ - expected: '36', found: '18'