- 求和
- 2016-08-27 20:22:18 @
var
i,j,k,m,n,ans:longint;
col,num:array[0..100001]of longint;
begin
readln(n,m);
for i:=1 to n do
read(num[i]);
readln;
for i:=1 to n do
read(col[i]);
readln;
ans:=0;
for i:=1 to n-2 do
begin
j:=i+2;
while j<= n do
begin
if col[i]=col[j]
then
ans:=(ans+(num[i]+num[j])*(i+j))mod 10007;
j:=j+2;
end;
end;
writeln(ans);
end.
1 条评论
-
larryzhong LV 9 @ 2016-11-17 21:33:14
#include <iostream>
using namespace std;typedef struct
{
int number;
int color;
} paper;int main()
{
ios::sync_with_stdio(false);
int n, m;
cin>>n>>m;
paper a[n];
for (int i=0; i<n; i++)
cin>>a[i].number;
for (int i=0; i<n; i++)
cin>>a[i].color;
int sum = 0;
for (int x=0; x<n-2; x++)
for (int y=x+1; 2*y-x<n; y++)
{
int z = 2 * y - x;
if (a[x].color == a[z].color)
{
sum += (x+z+2) * (a[x].number+a[z].number);
sum %= 10007;
}
}
cout<<sum<<endl;return 0;
}
- 1
信息
- ID
- 1976
- 难度
- 8
- 分类
- (无)
- 标签
- 递交数
- 3003
- 已通过
- 400
- 通过率
- 13%
- 被复制
- 16
- 上传者