結果

問題 No.1201 お菓子配り-4
ユーザー beetbeet
提出日時 2020-08-28 22:29:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,945 ms / 4,000 ms
コード長 959 bytes
コンパイル時間 1,930 ms
コンパイル使用メモリ 195,648 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 13:25:38
合計ジャッジ時間 13,868 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
6,812 KB
testcase_01 AC 415 ms
6,940 KB
testcase_02 AC 610 ms
6,940 KB
testcase_03 AC 297 ms
6,940 KB
testcase_04 AC 142 ms
6,940 KB
testcase_05 AC 362 ms
6,940 KB
testcase_06 AC 56 ms
6,940 KB
testcase_07 AC 164 ms
6,940 KB
testcase_08 AC 444 ms
6,940 KB
testcase_09 AC 326 ms
6,944 KB
testcase_10 AC 4 ms
6,940 KB
testcase_11 AC 88 ms
6,940 KB
testcase_12 AC 690 ms
6,940 KB
testcase_13 AC 20 ms
6,940 KB
testcase_14 AC 11 ms
6,940 KB
testcase_15 AC 541 ms
6,944 KB
testcase_16 AC 162 ms
6,944 KB
testcase_17 AC 210 ms
6,944 KB
testcase_18 AC 36 ms
6,944 KB
testcase_19 AC 34 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 1 ms
6,944 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 878 ms
6,944 KB
testcase_31 AC 882 ms
6,944 KB
testcase_32 AC 862 ms
6,940 KB
testcase_33 AC 870 ms
6,940 KB
testcase_34 AC 884 ms
6,940 KB
testcase_35 AC 1,945 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using Int = long long;
const char newl = '\n';

const unsigned int MOD = 1e9+7;
// sum_{i=0}^{n-1} (ai + b) // m
// 0 <= a, b
template<typename T>
inline T sum_of_floor(T n,T a){
  T res=0;
  while(1){
    if(a>=n){
      res+=(n-1)*n*(a/n)/2;
      a%=n;
    }
    T y=a;
    if(y==0) return res;
    T nn=y;
    T na=n;
    n=nn;
    a=na;
  }
  cout<<newl;
  return res;
}

//INSERT ABOVE HERE
using ull = unsigned long long;
const int MAX = 2020;
ull as[MAX];
ull bs[MAX];

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  ull n,m;
  cin>>n>>m;
  for(ull i=0;i<n;i++) cin>>as[i];
  for(ull j=0;j<m;j++) cin>>bs[j];

  vector<ull> ans(m);
  for(ull i=0;i<n;i++)
    for(ull j=0;j<m;j++)
      ans[j]+=sum_of_floor(bs[j],as[i]);

  ull res=0;
  for(ull j=0;j<m;j++){
    res+=ans[j]%MOD;
    res%=MOD;
  }

  for(ull i=0;i<n;i++) res+=as[i]*m;

  res*=2;
  res%=MOD;
  cout<<res<<newl;
  return 0;
}
0