結果
| 問題 | No.2821 A[i] ← 2A[j] - A[i] |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2024-07-29 17:20:42 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 729 bytes |
| 記録 | |
| コンパイル時間 | 145 ms |
| コンパイル使用メモリ | 52,880 KB |
| 実行使用メモリ | 9,268 KB |
| 最終ジャッジ日時 | 2026-07-05 08:54:57 |
| 合計ジャッジ時間 | 2,045 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 21 WA * 12 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2821.cc: No.2821 A[i] 竊・2A[j] - A[i] - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 300000;
/* typedef */
using ll = long long;
/* global variables */
ll as[MAX_N], ds[MAX_N];
/* subroutines */
template <typename T>
T gcd(T m, T n) { // m >= 0, n >= 0
if (m < n) swap(m, n);
while (n > 0) {
T r = m % n;
m = n;
n = r;
}
return m;
}
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%lld", as + i);
ds[0] = 0;
for (int i = 1; i < n; i++)
ds[i] = gcd(ds[i - 1], abs(as[i] - as[0]));
for (int i = 0; i < n; i++) printf("%d\n", ds[i]);
return 0;
}
tnakao0123