結果

問題 No.896 友達以上恋人未満
ユーザー Lepton_sLepton_s
提出日時 2018-01-23 23:32:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,135 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 32,400 KB
実行使用メモリ 173,024 KB
最終ジャッジ日時 2023-09-02 12:29:18
合計ジャッジ時間 13,719 ms
ジャッジサーバーID
(参考情報)
judge16 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cassert>
using namespace std;
typedef long long ll;
#define N (1<<25)
int m, n, mx, ax, my, ay, mod, q;
ll x[N], y[N], z[N];
bool prime[N];

int main(){
	scanf("%d%d%d%d%d%d%d",&m,&n,&mx,&ax,&my,&ay,&mod);
	/*assert(1<=m&&m<=100);
	assert(m<=n&&n<=10000000);
	assert(1<=mod&&mod<=1<<23);
	assert(__builtin_popcount(mod)==1);
	assert(0<=mx&&mx<mod);
	assert(0<=ax&&ax<mod);
	assert(0<=my&&my<mod);
	assert(0<=ay&&ay<mod);*/
	for(int i = 0; i < m; i++) scanf("%d", x+i);
	for(int i = 0; i < m; i++) scanf("%d", y+i);
	for(int i = 0; i < m; i++) z[x[i]] += y[i];
	ll xx = x[m-1], yy = y[m-1];
	for(int i = m; i < n; i++){
		xx = (xx*mx+ax)&(mod-1);
		yy = (yy*my+ay)&(mod-1);
		z[xx] += yy;
	}
	for(int i = 2; i*i<N; i++){
		if(prime[i]) continue;
		for(int j = i*i; j<N; j+=i){
			prime[j] = true;
		}
	}
	for(int i = 2; i < N; i++){
		if(prime[i]) continue;
		for(int j = (N-1)/i*i; j > 0; j-=i){
			z[j/i] += z[j];
		}
	}
	scanf("%d", &q);
	//assert(1<=q&&q<=100000);
	while(q--){
		int a, b;
		scanf("%d%d",&a,&b);
		assert(1<=a&&(ll)a<=1000000000/b&&a*b<=1000000000);
		printf("%lld\n", z[a]-z[a*b]);
	}
}
0