結果

問題 No.751 Frac #2
ユーザー totori_nyaatotori_nyaa
提出日時 2019-07-17 20:32:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 702 bytes
コンパイル時間 1,539 ms
コンパイル使用メモリ 164,152 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-24 21:07:41
合計ジャッジ時間 3,531 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,380 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
   int n;
   cin>>n;
   ll l=1,r=1;


   for(int i=0;i<n;i++){
       int a; cin>>a;
       if(i==0) l*=a;
       else if(i==1) r*=a;
       else if(i%2==0) r*=a;
       else l*=a; 
   }
   
   cin>>n;
   cerr<<l<<" "<<r<<endl;
   for(int i=2;i<=10;i++){
       while(l%i==0 && r%i==0){
           l/=i,r/=i;
       }
   }

   for(int i=0;i<n;i++){
       int a;
       cin>>a;
       if(i%2) l*=a;
       else r*=a;
   }
   for(int i=2;i<=10;i++){
       while(l%i==0 && r%i==0){
           l/=i,r/=i;
       }
   }
   if(r<0) l*=-1,r*=-1;
   cout<<l<<" "<<r<<endl;

 
}
0