UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214291#3851. 多项式乘法drdilyor601315ms54968kbC++111.3kb2024-11-17 08:50:202024-11-17 13:05:27

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
void ts(){cout<<"IAKIOI\n";}
inline int read(){
	int n=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		n=n*10+ch-'0';
		ch=getchar();
	}
	return n*f;
}
int n,m,q;
int a[200005],b[200005];
vector<int> fac[200005];
vector<pair<int,int>> que[200005];
int ans[200005];
vector<int> vis[200005];
signed main(){
	n=read(),m=read(),q=read();
	for(int i=0;i<=n;i++)a[i]=read();
	for(int i=0;i<=n;i++)b[i]=read();
	for(int i=1;i<=m;i++){
		for(int j=i;j<=m;j+=i)fac[j].push_back(i);
	}
	for(int i=1;i<=q;i++){
		int c=read(),d=read();
		que[c].push_back({d,i});
	}
	for(int c=1;c<=m;c++){
		for(int j=0;j<(int)que[c].size();j++){
			vis[que[c][j].first].push_back(que[c][j].second);
		}
		for(int i=0;i*c<=m;i++){
			int p=m-i*c;
			if(!p){
				for(int j=0;j<(int)que[c].size();j++){
					ans[que[c][j].second]+=a[i]*b[0];
				}
				continue;
			}
			for(auto d:fac[p]){
				for(auto qid:vis[d]){
					ans[qid]+=a[i]*b[p/d];
				}
			}
		}
		for(int j=0;j<(int)que[c].size();j++){
			vis[que[c][j].first].clear();
		}
	}
	for(int i=1;i<=q;i++)printf("%lld\n",ans[i]);
	return 0;
}
//look at my code
//my code is amazing

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 6ms
memory: 15428kb

input:

999 996 1000
181 806 745 589 721 351 654 278 172 787 785 328 876 63 436 237 822 649 932 55 332 99 13...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 tokens

Test #2:

score: 10
Accepted
time: 4ms
memory: 15424kb

input:

999 999 998
629 817 295 274 803 741 680 334 314 300 960 880 958 153 650 621 830 812 753 954 925 128 ...

output:

0
0
0
0
0
573534
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 998 tokens

Test #3:

score: 10
Accepted
time: 3ms
memory: 15428kb

input:

999 1000 996
405 332 85 45 221 452 98 110 660 639 88 132 660 917 688 160 46 739 398 344 813 746 593 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
87480
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 996 tokens

Test #4:

score: 10
Accepted
time: 6ms
memory: 15428kb

input:

1000 998 998
166 218 178 246 965 67 723 748 446 558 450 939 19 72 123 256 942 873 269 573 991 463 68...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 998 tokens

Test #5:

score: 10
Accepted
time: 613ms
memory: 54952kb

input:

199997 199999 199998
1302 180172 139335 170014 31751 7467 183386 71639 67797 140829 155107 61564 984...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 199998 tokens

Test #6:

score: 10
Accepted
time: 683ms
memory: 54968kb

input:

199997 199997 200000
84501 46291 64694 156236 116548 147672 10286 54151 157755 190434 70365 145475 1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 200000 tokens

Test #7:

score: 0
Time Limit Exceeded

input:

200000 199996 199997
10072 125769 117200 152038 170661 109407 73931 21884 144280 181053 47148 44210 ...

output:


result:


Test #8:

score: 0
Time Limit Exceeded

input:

200000 200000 200000
94005 71739 112951 57403 31797 74173 113981 44673 166545 101677 135207 32182 50...

output:


result:


Test #9:

score: 0
Time Limit Exceeded

input:

199997 199998 199997
114782 89426 5154 72561 99785 66889 106549 2708 46310 108849 58268 188339 12902...

output:


result:


Test #10:

score: 0
Time Limit Exceeded

input:

199998 199997 199997
194270 184004 139383 148257 117737 8328 66533 187509 47247 118806 176038 42976 ...

output:


result: