結果

問題 No.1201 お菓子配り-4
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2020-08-26 18:33:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,069 ms / 4,000 ms
コード長 871 bytes
コンパイル時間 2,398 ms
コンパイル使用メモリ 196,868 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 03:34:30
合計ジャッジ時間 14,812 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
5,248 KB
testcase_01 AC 449 ms
5,248 KB
testcase_02 AC 644 ms
5,376 KB
testcase_03 AC 315 ms
5,376 KB
testcase_04 AC 155 ms
5,376 KB
testcase_05 AC 387 ms
5,376 KB
testcase_06 AC 63 ms
5,376 KB
testcase_07 AC 177 ms
5,376 KB
testcase_08 AC 484 ms
5,376 KB
testcase_09 AC 359 ms
5,376 KB
testcase_10 AC 5 ms
5,376 KB
testcase_11 AC 92 ms
5,376 KB
testcase_12 AC 726 ms
5,376 KB
testcase_13 AC 22 ms
5,376 KB
testcase_14 AC 12 ms
5,376 KB
testcase_15 AC 581 ms
5,376 KB
testcase_16 AC 176 ms
5,376 KB
testcase_17 AC 232 ms
5,376 KB
testcase_18 AC 39 ms
5,376 KB
testcase_19 AC 37 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 941 ms
5,376 KB
testcase_31 AC 932 ms
5,376 KB
testcase_32 AC 927 ms
5,376 KB
testcase_33 AC 936 ms
5,376 KB
testcase_34 AC 929 ms
5,376 KB
testcase_35 AC 2,069 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++){
    cin>>a.at(i);
    assert(a.at(i)>=0&&a.at(i)<=100000000);
  }
   for(int i=0;i<m;i++){
    cin>>b.at(i);
          assert(b.at(i)>=1&&b.at(i)<=100000000);
  }
 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