結果

問題 No.1201 お菓子配り-4
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2020-07-21 18:18:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,296 ms / 4,000 ms
コード長 711 bytes
コンパイル時間 898 ms
コンパイル使用メモリ 83,808 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 03:34:47
合計ジャッジ時間 15,769 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
5,248 KB
testcase_01 AC 504 ms
5,376 KB
testcase_02 AC 721 ms
5,376 KB
testcase_03 AC 353 ms
5,376 KB
testcase_04 AC 172 ms
5,376 KB
testcase_05 AC 427 ms
5,376 KB
testcase_06 AC 66 ms
5,376 KB
testcase_07 AC 198 ms
5,376 KB
testcase_08 AC 547 ms
5,376 KB
testcase_09 AC 402 ms
5,376 KB
testcase_10 AC 5 ms
5,376 KB
testcase_11 AC 104 ms
5,376 KB
testcase_12 AC 834 ms
5,376 KB
testcase_13 AC 24 ms
5,376 KB
testcase_14 AC 13 ms
5,376 KB
testcase_15 AC 648 ms
5,376 KB
testcase_16 AC 199 ms
5,376 KB
testcase_17 AC 255 ms
5,376 KB
testcase_18 AC 43 ms
5,376 KB
testcase_19 AC 40 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 2 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,038 ms
5,376 KB
testcase_31 AC 1,046 ms
5,376 KB
testcase_32 AC 1,045 ms
5,376 KB
testcase_33 AC 1,047 ms
5,376 KB
testcase_34 AC 1,042 ms
5,376 KB
testcase_35 AC 2,296 ms
5,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