結果
| 問題 |
No.1201 お菓子配り-4
|
| コンテスト | |
| ユーザー |
tute7627
|
| 提出日時 | 2020-08-28 22:13:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 819 bytes |
| コンパイル時間 | 2,341 ms |
| コンパイル使用メモリ | 193,704 KB |
| 最終ジャッジ日時 | 2025-01-13 17:57:51 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 TLE * 1 |
ソースコード
#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;
}
tute7627