結果

問題 No.1201 お菓子配り-4
ユーザー kotatsugamekotatsugame
提出日時 2020-11-27 09:57:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 727 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 63,792 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-10-01 03:59:50
合計ジャッジ時間 51,002 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
7,700 KB
testcase_01 AC 1,973 ms
4,380 KB
testcase_02 AC 2,850 ms
4,376 KB
testcase_03 AC 1,390 ms
4,376 KB
testcase_04 AC 675 ms
4,376 KB
testcase_05 AC 1,676 ms
4,380 KB
testcase_06 AC 254 ms
4,380 KB
testcase_07 AC 758 ms
4,376 KB
testcase_08 AC 2,119 ms
4,380 KB
testcase_09 AC 1,557 ms
4,380 KB
testcase_10 AC 13 ms
4,376 KB
testcase_11 AC 401 ms
4,376 KB
testcase_12 AC 3,247 ms
4,376 KB
testcase_13 AC 88 ms
4,376 KB
testcase_14 AC 44 ms
4,380 KB
testcase_15 AC 2,548 ms
4,376 KB
testcase_16 AC 777 ms
4,376 KB
testcase_17 AC 1,000 ms
4,376 KB
testcase_18 AC 161 ms
4,376 KB
testcase_19 AC 152 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
a.cpp:6:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]

ソースコード

diff #

#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;
}
0