- 求和
- 2015-11-09 11:29:02 @
且不存在出现次数超过 20 的颜色
随机就随机吧,至少要符合限制啊。。
4 条评论
-
larryzhong LV 9 @ 2016-11-17 21:33:30
#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;
} -
2016-06-10 21:16:08@
代码
var n,m,i,sum:longint;
num,color,t,tc,tn,tm:array[1..100000]of Int64;begin
read(n,m);
for i:=1 to n do
read(num[i]);
for i:=1 to n do
read(color[i]);
fillchar(t,sizeof(t),0);
fillchar(tc,sizeof(tc),0);
fillchar(tn,sizeof(tn),0);
fillchar(tm,sizeof(tm),0);
sum:=0;
i:=1;
while i<=n do
begin
inc(t[color[i]]);
inc(tc[color[i]],i*num[i]);
inc(tn[color[i]],num[i]);
inc(tm[color[i]],i);
inc(i,2);
end;
for i:=1 to m do
if t[i]>1 then
sum:=(sum+(t[i]-2)*tc[i]+tn[i]*tm[i])mod 10007;
fillchar(t,sizeof(t),0);
fillchar(tc,sizeof(tc),0);
fillchar(tn,sizeof(tn),0);
fillchar(tm,sizeof(tm),0);
i:=2;
while i<=n do
begin
inc(t[color[i]]);
inc(tc[color[i]],i*num[i]);
inc(tn[color[i]],num[i]);
inc(tm[color[i]],i);
inc(i,2);
end;
for i:=1 to m do
if t[i]>1 then
sum:=(sum+(t[i]-2)*tc[i]+tn[i]*tm[i])mod 10007;
writeln(sum);
end. -
2015-11-09 14:47:07@
我错了嘛 >_< 我已经改了
-
2015-11-09 11:50:45@
AHdoc表示他没有看到这一行。
- 1
信息
- ID
- 1976
- 难度
- 8
- 分类
- (无)
- 标签
- 递交数
- 3003
- 已通过
- 400
- 通过率
- 13%
- 被复制
- 16
- 上传者