题解 「SWTR-04」Meeting in the Forest
Warriors_Cat · · 题解
1.\;10\;pts
送分的,答案就是
2.\;30\;pts
对于一个二次方程,用求根公式
3.\;60\;pts
这个其实只是用来凑数的,也不知道有什么方法。
4.\;100\;pts
下面来讲正解惹QAQ。
其实这道题是韦达定理的拓展应用,在这里就手推一下韦达定理吧。
首先,根据题目我们可以得到:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
#define int long long
const int mod = 1e9 + 7;
int n, a[200010], b[200010], c[200010], ans;
signed main(){
//freopen("test20.in", "r", stdin);
//freopen("test20.out", "w", stdout);
scanf("%lld", &n);
for(int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
for(int i = 1; i <= n; ++i) scanf("%lld", &b[i]);
for(int i = 1; i <= n; ++i){
if(i & 1) c[i] = -a[i];//奇数变为相反数
else c[i] = a[i];//否则还是自己
}
for(int i = 1; i <= n; ++i) ans = (ans + b[i] * c[i] % mod) % mod;//答案累加
printf("%lld", (ans + mod) % mod);//注意负数的判断QAQ
return 0;//完结撒花
}