結果

問題 No.896 友達以上恋人未満
ユーザー kotatsugamekotatsugame
提出日時 2019-09-27 23:14:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,595 ms / 3,500 ms
コード長 969 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 39,804 KB
実行使用メモリ 81,664 KB
最終ジャッジ日時 2023-10-25 06:17:56
合計ジャッジ時間 5,863 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 465 ms
36,608 KB
testcase_06 AC 783 ms
36,608 KB
testcase_07 AC 450 ms
36,608 KB
testcase_08 AC 450 ms
36,608 KB
testcase_09 AC 1,066 ms
69,376 KB
testcase_10 AC 1,595 ms
81,664 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<cstdio>
#include<cmath>
using namespace std;
int M,N,mulX,addX,mulY,addY,mod;
long Z[1<<24];
int X[1000];
int LX,LY,LA,LB;
main()
{
	scanf("%d%d%d%d%d%d%d",&M,&N,&mulX,&addX,&mulY,&addY,&mod);
	for(int i=0;i<M;i++)scanf("%d",X+i);
	for(int i=0;i<M;i++)
	{
		scanf("%d",&LY);
		Z[X[i]]+=LY;
	}
	LX=X[M-1];
	for(int i=M;i<N;i++)
	{
		LX=((long)LX*mulX+addX)&(mod-1);
		LY=((long)LY*mulY+addY)&(mod-1);
		Z[LX]+=LY;
	}
	Z[0]=0;
	for(int i=1;i<mod/2;i++)
	{
		for(int j=i+i;j<mod;j+=i)Z[i]+=Z[j];
	}
	for(int i=0;i<M;i++)scanf("%d",X+i);
	long ans=0;
	for(int i=0;i<M;i++)
	{
		scanf("%d",&LB);
		long now=X[i]<mod?Z[X[i]]:0;
		if((long)X[i]*LB>=mod);
		else
		{
			now-=Z[X[i]*LB];
		}
		ans^=now;
		printf("%ld\n",now);
	}
	LA=X[M-1];
	for(int i=M;i<N;i++)
	{
		LA=((long)LA*mulX+addX+mod-1)&(mod-1);
		LB=((long)LB*mulY+addY+mod-1)&(mod-1);
		LA+=1;
		LB+=1;
		long now=LA<mod?Z[LA]:0;
		if((long)LA*LB<mod)now-=Z[LA*LB];
		ans^=now;
	}
	printf("%ld\n",ans);
}
0