結果

問題 No.1201 お菓子配り-4
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2020-08-22 13:34:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,302 ms / 4,000 ms
コード長 868 bytes
コンパイル時間 2,438 ms
コンパイル使用メモリ 198,644 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 03:36:51
合計ジャッジ時間 16,220 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
5,248 KB
testcase_01 AC 479 ms
5,376 KB
testcase_02 AC 698 ms
5,376 KB
testcase_03 AC 334 ms
5,376 KB
testcase_04 AC 166 ms
5,376 KB
testcase_05 AC 424 ms
5,376 KB
testcase_06 AC 66 ms
5,376 KB
testcase_07 AC 193 ms
5,376 KB
testcase_08 AC 537 ms
5,376 KB
testcase_09 AC 395 ms
5,376 KB
testcase_10 AC 5 ms
5,376 KB
testcase_11 AC 103 ms
5,376 KB
testcase_12 AC 820 ms
5,376 KB
testcase_13 AC 25 ms
5,376 KB
testcase_14 AC 13 ms
5,376 KB
testcase_15 AC 648 ms
5,376 KB
testcase_16 AC 198 ms
5,376 KB
testcase_17 AC 254 ms
5,376 KB
testcase_18 AC 43 ms
5,376 KB
testcase_19 AC 41 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 1,036 ms
5,376 KB
testcase_31 AC 1,036 ms
5,376 KB
testcase_32 AC 1,038 ms
5,376 KB
testcase_33 AC 1,038 ms
5,376 KB
testcase_34 AC 1,038 ms
5,376 KB
testcase_35 AC 2,302 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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)>=0&&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