結果

問題 No.2821 A[i] ← 2A[j] - A[i]
ユーザー HIcoder
提出日時 2024-12-16 23:51:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 549 ms / 1,500 ms
コード長 775 bytes
コンパイル時間 1,076 ms
コンパイル使用メモリ 114,128 KB
最終ジャッジ日時 2025-02-26 14:55:26
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<cassert>
#include<random>
#include<set>
#include<map>
#include<cassert>
#include<unordered_map>
#include<bitset>
#include<numeric>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=1<<30;
const ll INF=1LL<<62;
typedef pair<int,ll> P;
typedef pair<int,P> PP; 
const ll MOD=998244353;
const int MAXN=3*1000000;

ll gcd(ll x,ll y){
    if(x<y) swap(x,y);
    //x>=y
    return y==0?x:gcd(y,x%y);
}

int main(){
    int N;
    cin>>N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    vector<ll> ans(N+1);
    for(int i=0;i<N;i++){
        ans[i+1]=gcd(ans[i],abs(A[i]-A[0]));
    } 
    for(int i=1;i<=N;i++){
        cout<<ans[i]<<endl;
    }

}
0