結果

問題 No.1201 お菓子配り-4
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2020-07-21 18:16:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,276 ms / 4,000 ms
コード長 711 bytes
コンパイル時間 650 ms
コンパイル使用メモリ 81,984 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-07 09:32:17
合計ジャッジ時間 14,892 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
4,376 KB
testcase_01 AC 498 ms
4,380 KB
testcase_02 AC 714 ms
4,380 KB
testcase_03 AC 348 ms
4,380 KB
testcase_04 AC 170 ms
4,376 KB
testcase_05 AC 421 ms
4,380 KB
testcase_06 AC 65 ms
4,376 KB
testcase_07 AC 190 ms
4,376 KB
testcase_08 AC 531 ms
4,376 KB
testcase_09 AC 391 ms
4,380 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 102 ms
4,380 KB
testcase_12 AC 813 ms
4,376 KB
testcase_13 AC 24 ms
4,380 KB
testcase_14 AC 12 ms
4,380 KB
testcase_15 AC 642 ms
4,380 KB
testcase_16 AC 196 ms
4,376 KB
testcase_17 AC 252 ms
4,376 KB
testcase_18 AC 42 ms
4,380 KB
testcase_19 AC 39 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1,026 ms
4,380 KB
testcase_31 AC 1,027 ms
4,380 KB
testcase_32 AC 1,028 ms
4,380 KB
testcase_33 AC 1,029 ms
4,376 KB
testcase_34 AC 1,026 ms
4,380 KB
testcase_35 AC 2,276 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <random>
using namespace std;
using ll = long long;
ll mygcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(mygcd(b, a%b));
   }
}
int main(){
 ll n,m;
  cin>>n>>m;
  vector<ll> a(n);
  vector<ll> b(m);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<m;i++){
    cin>>b.at(i);
  }
 ll ans=0;
  ll x,y;
  x=0;
  y=0;
  for(int i=0;i<n;i++){
    x=(x+a.at(i)-1)%1000000007;
  }
  for(int i=0;i<m;i++){
    y=(y+b.at(i)+1)%1000000007;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      ans=(ans+mygcd(a.at(i),b.at(j)))%1000000007;
    }
  }
  ans=(ans+((x*y)%1000000007)+((m*n)%1000000007))%1000000007;
  cout<<ans<<endl;
}
0