結果
問題 | No.751 Frac #2 |
ユーザー |
![]() |
提出日時 | 2020-03-14 20:49:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 486 bytes |
コンパイル時間 | 1,879 ms |
コンパイル使用メモリ | 191,404 KB |
最終ジャッジ日時 | 2025-01-09 06:55:54 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
#include<bits/stdc++.h> #define endl enjoy_codeforces using lint=long long; int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); lint a=1,b=1; lint n;std::cin>>n; lint x; for(lint i=0;i<n;i++){ std::cin>>x; (i?b:a)*=x; } std::cin>>n; for(lint i=0;i<n;i++){ lint x;std::cin>>x; (i%2?a:b)*=x; } if(b<0)a=-a,b=-b; lint g=std::__gcd(a,b); if(g<0)g=-g; std::cout<<a/g<<" "<<b/g<<'\n'; }