QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#43123 | #1842. Math | yzhang | WA | 1ms | 5764kb | C++ | 1.1kb | 2022-08-08 11:05:42 | 2022-08-08 11:05:44 |
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]]){
ll v0=0,v1=i*i;
while(v0<=1000000){
ans+=1ll*cnt[a[i]]*cnt[v0];
v0+=v1+v1+1;
++v1;
}
}
printf("%lld\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5764kb
input:
5 1 2 3 4 5
output:
1
result:
wrong answer 1st numbers differ - expected: '2', found: '1'