ACdream 1029 前缀和
Multiplication
Problem Description
If C=A⋄B, then
.
Work out sequence C=A⋄Bfor 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 nn integers a1,a2,…,ana1,a2,…,an , which denote sequence A.
The thrid line contains nn integers b1,b2,…,bnb1,b2,…,bn , which denote sequenceB.
(1≤n≤105,0≤ai,bi≤109)
Output
nn integers, which denotes sequence C.
Sample Input
2
1 2
3 4
Sample Output
3 18
Source
Manager
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#define ll long long
#define pi acos(-1.0)
#define mod 1000000007
using namespace std;
int n;
ll a[];
ll b[];
ll suma[];
ll sumb[];
ll ans;
ll gg[];
int main()
{
while(scanf("%d",&n)!=EOF)
{
suma[]=;
sumb[]=;
a[]=;
b[]=;
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
suma[i]=(suma[i-]+a[i])%mod;
}
for(int i=;i<=n;i++)
{
scanf("%d",&b[i]);
sumb[i]=(sumb[i-]+b[i])%mod;
}
ans=;
for(int i=;i<=n;i++)
{
ans=((a[i]*b[i]%mod+a[i]*sumb[i-]%mod+b[i]*suma[i-]%mod))%mod;
gg[i]=ans;
}
printf("%lld",gg[]);
for(int i=;i<=n;i++)
printf(" %lld",gg[i]);
cout<<endl;
}
return ;
}
ACdream 1029 前缀和的更多相关文章
- Leetcode 1029. 可被 5 整除的二进制前缀
1029. 可被 5 整除的二进制前缀 显示英文描述 我的提交返回竞赛 用户通过次数467 用户尝试次数662 通过次数477 提交次数1964 题目难度Easy 给定由若干 0 和 1 组成的 ...
- HDU 5452——Minimum Cut——————【树链剖分+差分前缀和】ACdream 1429——Diversion——————【树链剖分】
Minimum Cut Time Limit: 3000/2000 MS (Java/Others) Memory Limit: 65535/102400 K (Java/Others)Tota ...
- [ACDream 1430]SETI 后缀数组
题目链接:http://acdream.info/problem?pid=1430 题目大意:给你一个长度不超过10000的字符串,问你出现过两次或两次以上的不重叠的子串有多少个. 后缀数组计算出he ...
- [ACdream] 女神教你字符串——三个气球
Problem Description 女神邀请众ACdream开联欢会,显然作为ACM的佼佼者,气球是不能少的~.女神准备了三种颜色的气球,红色,黄色,绿色(交通信号灯?) 有气球还不能满足女神,女 ...
- ACdreamoj 1011(树状数组维护字符串hash前缀和)
题目链接:http://acdream.info/problem? pid=1019 题意:两种操作,第一种将字符串某个位置的字符换为还有一个字符.另外一种查询某个连续子序列是否是回文串: 解法:有两 ...
- ACdream1726-A Math game+(DFS+二分)+(DFS+前缀和)
传送门 官方题解:http://acdream.info/topic?tid=4246 参考:https://www.cnblogs.com/nowandforever/p/4492428.html ...
- HDU1671——前缀树的一点感触
题目http://acm.hdu.edu.cn/showproblem.php?pid=1671 题目本身不难,一棵前缀树OK,但是前两次提交都没有成功. 第一次Memory Limit Exceed ...
- 【手记】注意BinaryWriter写string的小坑——会在string前加上长度前缀length-prefixed
之前以为BinaryWriter写string会严格按构造时指定的编码(不指定则是无BOM的UTF8)写入string的二进制,如下面的代码: //将字符串"a"写入流,再拿到流的 ...
- ASP.NET Core MVC 配置全局路由前缀
前言 大家好,今天给大家介绍一个 ASP.NET Core MVC 的一个新特性,给全局路由添加统一前缀.严格说其实不算是新特性,不过是Core MVC特有的. 应用背景 不知道大家在做 Web Ap ...
随机推荐
- mybatis异常:Could not find result map ......... 问题分析及解决
org.apache.ibatis.builder.IncompleteElementException: Could not find result map....... 网上的大部分的改正方法是: ...
- linux 安装nginx yum
本分类下有一个环境一键安装.那这背后发生了什么呢?咱们手动使用源码进行安装.1.首先保证有一个能联网的centos.2.百度 ningx 官网 点download http://nginx.or ...
- opencv 图像的线性混合
1 线性混合理论 g(x) = (1-α)*f1(x) + α*f2(x) 其中,α代表图像的权重 #include<iostream> #include<opencv2/openc ...
- POJ:3040-Allowance(贪心好题)
Allowance Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4903 Accepted: 1943 Description ...
- java_servlet
在servlet 解决中文乱码 response.setContentType("text/html;charset=utf-8"); //必须在getWrite()上面,不然依然 ...
- User_Authentication_Personalization Model
花了一天时间实现了一个 简单的用户登录验证的小模型. 基本实现了现在 用户登录模块的绝大多数功能, 也算是 熟悉了一下系统的逻辑. 在这个小模型中, 实现了以下的基本功能 : Logging in a ...
- UOJ #2321. 「清华集训 2017」无限之环
首先裂点表示四个方向 一条边上都有插头或者都不有插头,相当于满足流量平衡 最大流 = 插头个数*2时有解 然后求最小费用最大流 黑白染色分别连原点汇点
- CentOS 单用户模式:修改Root密码和grub加密[转]
原文出处: http://zhengdl126.iteye.com/blog/430268 Linux 系统处于正常状态时,服务器主机开机(或重新启动)后,能够由系统引导器程序自动引导 Linux 系 ...
- 【HTML&CSS】 第一章:DTD文档声明
<!DOCTYPE> 声明必须是 HTML 文档的第一行,位于 <html> 标签之前. <!DOCTYPE> 声明不是 HTML 标签:它是指示 web 浏览器关 ...
- postman导出excel出现response
https://jingyan.baidu.com/article/915fc414559b4351394b2084.html