結果

問題 No.1201 お菓子配り-4
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2020-08-26 18:32:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 868 bytes
コンパイル時間 2,403 ms
コンパイル使用メモリ 196,492 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-25 03:37:03
合計ジャッジ時間 9,031 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <random>
#include <bits/stdc++.h>
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;
  assert(1<=n&&n<=2000&&1<=m&&m<=2000);
  vector<ll> a(n);
  vector<ll> b(m);
  for(int i=0;i<n;i++){
      assert(a.at(i)>=0&&a.at(i)<=100000000);
    cin>>a.at(i);
  }
  for(int i=0;i<m;i++){
      assert(b.at(i)>=1&&b.at(i)<=100000000);
    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