結果

問題 No.1201 お菓子配り-4
ユーザー kotatsugamekotatsugame
提出日時 2020-11-27 10:00:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 655 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 64,004 KB
実行使用メモリ 9,008 KB
最終ジャッジ日時 2023-10-01 04:00:24
合計ジャッジ時間 32,273 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
7,548 KB
testcase_01 AC 1,168 ms
4,376 KB
testcase_02 AC 1,670 ms
4,376 KB
testcase_03 AC 803 ms
4,376 KB
testcase_04 AC 394 ms
4,376 KB
testcase_05 AC 979 ms
4,380 KB
testcase_06 AC 148 ms
4,376 KB
testcase_07 AC 444 ms
4,376 KB
testcase_08 AC 1,243 ms
4,376 KB
testcase_09 AC 916 ms
4,376 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 241 ms
4,376 KB
testcase_12 AC 1,898 ms
4,380 KB
testcase_13 AC 53 ms
4,380 KB
testcase_14 AC 27 ms
4,376 KB
testcase_15 AC 1,549 ms
4,380 KB
testcase_16 AC 459 ms
4,380 KB
testcase_17 AC 589 ms
4,380 KB
testcase_18 AC 94 ms
4,380 KB
testcase_19 AC 88 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2,402 ms
4,380 KB
testcase_31 AC 2,409 ms
4,376 KB
testcase_32 AC 2,413 ms
4,380 KB
testcase_33 AC 2,405 ms
4,376 KB
testcase_34 AC 2,474 ms
4,376 KB
testcase_35 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:26:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   26 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
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;
	long long TX=(Xm+A-1)/A;
	ans+=(N-TX)*Ym;
	ans+=floor_sum(Ym,A,M,TX*A-Xm);
	return ans;
}
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