結果

問題 No.1201 お菓子配り-4
ユーザー 👑 tute7627tute7627
提出日時 2020-08-28 22:15:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 962 bytes
コンパイル時間 2,247 ms
コンパイル使用メモリ 199,472 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-26 13:16:36
合計ジャッジ時間 43,357 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
10,012 KB
testcase_01 AC 1,622 ms
5,376 KB
testcase_02 AC 2,348 ms
5,376 KB
testcase_03 AC 1,132 ms
5,376 KB
testcase_04 AC 552 ms
5,376 KB
testcase_05 AC 1,383 ms
5,376 KB
testcase_06 AC 209 ms
5,376 KB
testcase_07 AC 622 ms
5,376 KB
testcase_08 AC 1,736 ms
5,376 KB
testcase_09 AC 1,275 ms
5,376 KB
testcase_10 AC 11 ms
5,376 KB
testcase_11 AC 330 ms
5,376 KB
testcase_12 AC 2,662 ms
5,376 KB
testcase_13 AC 73 ms
5,376 KB
testcase_14 AC 37 ms
5,376 KB
testcase_15 AC 2,090 ms
5,376 KB
testcase_16 AC 634 ms
5,376 KB
testcase_17 AC 817 ms
5,376 KB
testcase_18 AC 133 ms
5,376 KB
testcase_19 AC 124 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 3,336 ms
5,376 KB
testcase_31 AC 3,345 ms
5,376 KB
testcase_32 AC 3,379 ms
5,376 KB
testcase_33 AC 3,372 ms
5,376 KB
testcase_34 AC 3,355 ms
5,376 KB
testcase_35 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

lint sum_of_floor_linear(lint a,lint b,lint c,lint n){
    lint tmp=b/c*n+a/c*n*(n-1)/2;
    if(a%c==0){
        return tmp;
    }
    lint next=(c-b%c+a%c-1)/(a%c);
    if(next>=n){
        return tmp;
    }
    a%=c;
    b=b%c+a*next;
    n-=next;
    return tmp+sum_of_floor_linear(c,n*a-((b+a*(n-1))/c*c-b),a,(b+a*(n-1))/c);
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n,m;cin>>n>>m;
  vector<int>a(n),b(m);
  const long long mod=1e9+7;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<m;i++)cin>>b[i];
  long long ret=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      long long add=sum_of_floor_linear(a[i],0,b[j],b[j]+1);
      //cout<<i spa j spa sum_of_floor_linear(a[i],0,b[j],b[j]+1)<<endl;
      ret=(ret+add*2)%mod;
    }
  }
  cout<<ret<<endl;
}
0