結果
| 問題 |
No.1201 お菓子配り-4
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-27 09:57:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 727 bytes |
| コンパイル時間 | 554 ms |
| コンパイル使用メモリ | 65,060 KB |
| 実行使用メモリ | 13,888 KB |
| 最終ジャッジ日時 | 2024-07-23 21:25:06 |
| 合計ジャッジ時間 | 49,550 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 TLE * 6 |
コンパイルメッセージ
a.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
ソースコード
#line 1 "a.cpp"
#include<iostream>
using namespace std;
#line 1 "/home/kotatsugame/library/math/floor_sum.cpp"
long long floor_sum(long long N,long long M,long long A,long long B)
//Sum[floor((A*i+B)/M),{i,0,N-1}]
{
long long ans=0;
if(A>=M)
{
ans+=N*(N-1)/2*(A/M);
A%=M;
}
if(B>=M)
{
ans+=N*(B/M);
B%=M;
}
long long Ym=(A*N+B)/M,Xm=Ym*M-B;
if(Ym==0)return ans;
ans+=(N-(Xm+A-1)/A)*Ym;
ans+=floor_sum(Ym,A,M,(A-Xm%A)%A);
return ans;
}
#line 4 "a.cpp"
int N,M;
int A[2000],B[2000];
main()
{
cin>>N>>M;
long ans=0;
for(int i=0;i<N;i++)cin>>A[i];
for(int i=0;i<M;i++)cin>>B[i];
for(int i=0;i<N;i++)for(int j=0;j<M;j++)
{
ans+=2*floor_sum(B[j],B[j],A[i],A[i]);
ans%=(int)1e9+7;
}
cout<<ans<<endl;
}