QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#43121#1842. MathyzhangWA 2ms3768kbC++1.1kb2022-08-08 11:04:272022-08-08 11:04:28

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-08 11:04:28]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3768kb
  • [2022-08-08 11:04:27]
  • 提交

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'