結果

問題 No.1201 お菓子配り-4
ユーザー 👑 tute7627tute7627
提出日時 2020-08-28 22:13:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 819 bytes
コンパイル時間 2,501 ms
コンパイル使用メモリ 197,284 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2024-04-26 13:12:10
合計ジャッジ時間 44,010 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
10,020 KB
testcase_01 AC 1,653 ms
6,820 KB
testcase_02 AC 2,381 ms
6,940 KB
testcase_03 AC 1,188 ms
6,940 KB
testcase_04 AC 568 ms
6,940 KB
testcase_05 AC 1,412 ms
6,940 KB
testcase_06 AC 212 ms
6,944 KB
testcase_07 AC 636 ms
6,944 KB
testcase_08 AC 1,773 ms
6,940 KB
testcase_09 AC 1,308 ms
6,944 KB
testcase_10 AC 12 ms
6,944 KB
testcase_11 AC 335 ms
6,940 KB
testcase_12 AC 2,708 ms
6,940 KB
testcase_13 AC 74 ms
6,944 KB
testcase_14 AC 38 ms
6,940 KB
testcase_15 AC 2,131 ms
6,944 KB
testcase_16 AC 646 ms
6,940 KB
testcase_17 AC 836 ms
6,940 KB
testcase_18 AC 135 ms
6,940 KB
testcase_19 AC 129 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 3,422 ms
6,944 KB
testcase_31 AC 3,469 ms
6,944 KB
testcase_32 AC 3,497 ms
6,944 KB
testcase_33 AC 3,437 ms
6,944 KB
testcase_34 AC 3,423 ms
6,940 KB
testcase_35 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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(){
  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%mod*2)%mod;
    }
  }
  cout<<ret<<endl;
}
0