結果

問題 No.2821 A[i] ← 2A[j] - A[i]
ユーザー Mohamed Thaer
提出日時 2025-05-15 05:05:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 66 ms / 1,500 ms
コード長 671 bytes
コンパイル時間 2,171 ms
コンパイル使用メモリ 195,644 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-05-15 05:05:21
合計ジャッジ時間 5,248 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void Thaer()’:
main.cpp:30:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:31:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define el '\n'
void Main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int &x: v)cin >> x;
    int64_t g = 0;
    cout << g << el;
    for (int i = 1; i < n; ++i) {
        g = gcd(abs(v[i]- v[i - 1]), g);
        cout << g << el;
    }
}
void Thaer();
int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    // Thaer();
    int T = 1;
    // cin >> T;
    for (int i = 1; i <= T; ++i) {
        Main();
        // if (i != T)cout << el;
    }
}
void Thaer() {
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
}
0