QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#43121 | #1842. Math | yzhang | WA | 2ms | 3768kb | C++ | 1.1kb | 2022-08-08 11:04:27 | 2022-08-08 11:04:28 |
Judging History
answer
//μ's forever
#include <bits/stdc++.h>
#define N 1000005
#define ll long long
//#define getchar nc
using namespace std;
inline char nc(){
static char buf[100000],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read()
{
register int x=0,f=1;register char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
return x*f;
}
inline void write(register int x)
{
if(!x)putchar('0');if(x<0)x=-x,putchar('-');
static int sta[20];register int tot=0;
while(x)sta[tot++]=x%10,x/=10;
while(tot)putchar(sta[--tot]+48);
}
int n,a[N],cnt[N];
ll ans=0;
int main()
{
n=read();
for(int i=1;i<=n;++i){
a[i]=read();
++cnt[a[i]];
}
for(int i=1;i<=1000000;++i)
if(cnt[a[i]]){
int v0=0,v1=i;
while(v0<=1000000){
ans+=1ll*cnt[a[i]]*cnt[v0];
v0+=v1+v1+1;
++v1;
}
}
printf("%lld\n",ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3580kb
input:
5 1 2 3 4 5
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3680kb
input:
1 1
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3768kb
input:
5 6 4 7 3 5
output:
3
result:
wrong answer 1st numbers differ - expected: '1', found: '3'