結果

問題 No.3020 ユークリッドの互除法・改
ユーザー wsrtrt
提出日時 2025-02-14 21:34:31
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,503 bytes
コンパイル時間 3,256 ms
コンパイル使用メモリ 282,724 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-14 21:35:54
合計ジャッジ時間 4,125 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define all(a) begin(a),end(a)
#define allr(a) rbegin(a),rend(a)
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())
using ll =long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi= vector<int>;
using vll =vector<ll>;
using vvi = vector<vector<int>>;
inline bool ingrid(int a,int b,int h,int w){
    return 0<=a&&a<h&&0<=b&&b<w;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int popcount(int t){return __builtin_popcount(t);}
int popcount(ll t){return __builtin_popcountll(t);}
struct Edge{
    int from,to;ll cost;int idx;
    Edge()=default;
    Edge(int from,int to,ll cost=1,int idx=-1):from(from),to(to),cost(cost),idx(idx){}
    operator int() const {return to;}
};


constexpr pii dx4[4]={{0,1},{0,-1},{1,0},{-1,0}};
constexpr pii dx[100]={};
#define endl '\n'
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector a(2,vector<ll>(2));
    rep(i,0,2){
        rep(j,0,2){
            cin>>a[i][j];
        }
    }
    ll d1=abs(gcd(gcd(a[0][0],a[0][1]),gcd(a[1][0],a[1][1])));
    ll d2=d1==0?0ll:abs(a[0][0]*a[1][1]-a[0][1]*a[1][0])/d1;
    cout<<d1<<' '<<d2<<endl;
    return 0;
}
0