Multiplication

题目

Multiplication

Time Limit: 4000/2000 MS (Java/Others)  Memory Limit: 128000/64000 KB (Java/Others)
Problem Description

If  C=AB , then

C[k]=max(i,j)=kA[i]B[j]mod(109+7)
.

Work out sequence  C=AB  for given sequence  A  and  B .

Input

The first line contains a integer  n , which denotes the length of sequence  A,B .

The second line contains  n  integers  a1,a2,,an , which denote sequence  A .

The thrid line contains  n  integers  b1,b2,,bn , which denote sequence B .

( 1n105,0ai,bi109 )

Output

n  integers, which denotes sequence  C .

Sample Input
2
1 2
3 4
Sample Output
3 18 


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

#define clr(a) memset(a,0,sizeof(a))
#define rep(i,s,t) for(int i=s;i<t;i++)

typedef long long ll;
const ll mod=1000000007;
const int N=100005;

int n;
ll a[N],b[N];
ll suma[N],sumb[N];

inline void In(){
	suma[0]=sumb[0]=0;
	rep(i,1,n+1){
		scanf("%lld",&a[i]);
		suma[i]=(suma[i-1]+a[i])%mod;
	}
	rep(i,1,n+1){
		scanf("%lld",&b[i]);
		sumb[i]=(sumb[i-1]+b[i])%mod;
	}
}

inline ll Ans(int k){
	ll ans1=a[k]*sumb[k]%mod;
	ll ans2=b[k]*suma[k]%mod;
	ll ans3=a[k]*b[k]%mod;
	return (ans1+ans2-ans3+mod)%mod;
}


inline void Work(){
	rep(i,1,n+1){
		printf("%lld",Ans(i));
		if(i==n) puts("");
		else putchar(' ');
	}
}
int main(){
	while(~scanf("%d",&n)){
		In();
		Work();
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值