結果

問題 No.1201 お菓子配り-4
ユーザー SSRSSSRS
提出日時 2020-08-28 21:56:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 955 bytes
コンパイル時間 2,456 ms
コンパイル使用メモリ 196,936 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-26 12:57:06
合計ジャッジ時間 42,018 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
8,576 KB
testcase_01 AC 1,542 ms
5,376 KB
testcase_02 AC 2,237 ms
5,376 KB
testcase_03 AC 1,082 ms
5,376 KB
testcase_04 AC 532 ms
5,376 KB
testcase_05 AC 1,292 ms
5,376 KB
testcase_06 AC 204 ms
5,376 KB
testcase_07 AC 594 ms
5,376 KB
testcase_08 AC 1,634 ms
5,376 KB
testcase_09 AC 1,201 ms
5,376 KB
testcase_10 AC 11 ms
5,376 KB
testcase_11 AC 315 ms
5,376 KB
testcase_12 AC 2,526 ms
5,376 KB
testcase_13 AC 68 ms
5,376 KB
testcase_14 AC 36 ms
5,376 KB
testcase_15 AC 1,968 ms
5,376 KB
testcase_16 AC 599 ms
5,376 KB
testcase_17 AC 795 ms
5,376 KB
testcase_18 AC 125 ms
5,376 KB
testcase_19 AC 119 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 3,215 ms
5,376 KB
testcase_31 AC 3,212 ms
5,376 KB
testcase_32 AC 3,190 ms
5,376 KB
testcase_33 AC 3,290 ms
5,376 KB
testcase_34 AC 3,337 ms
5,376 KB
testcase_35 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
//https://judge.yosupo.jp/submission/5724
long long sum_of_floor_linear(long long a, long long b, long long c, long long n){
    long long tmp=b/c*n+a/c*n*(n-1)/2;
    if(a%c==0){
        return tmp;
    }
    long long 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;
  cin >> N;
  int M;
  cin >> M;
  vector<long long> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<long long> B(M);
  for (int i = 0; i < M; i++){
    cin >> B[i];
  }
  long long ans = 0;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < M; j++){
      long long tmp = sum_of_floor_linear(A[i], A[i], B[j], B[j]);
      ans += tmp % MOD;
      ans %= MOD;
    }
  }
  ans *= 2;
  ans %= MOD;
  cout << ans << endl;
}
0