QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#752938 | #1842. Math | Wuyanru | WA | 5ms | 7948kb | C++14 | 956b | 2024-11-16 10:31:14 | 2024-11-16 10:31:17 |
Judging History
answer
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3fll
#define debug(x) cerr<<#x<<"="<<x<<endl
using namespace std;
using ll=long long;
using ld=long double;
using pli=pair<ll,int>;
using pi=pair<int,int>;
template<typename A>
using vc=vector<A>;
inline int read()
{
int s=0,w=1;char ch;
while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1;
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
inline ll lread()
{
ll s=0,w=1;char ch;
while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1;
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
const int L=1000000;
bool vis[1000001];
int a[1000001];
int n;
int main()
{
n=read();int ans=0;
for(int i=1;i<=n;i++) vis[a[i]=read()]=1;
for(int i=1;i<=n;i++)
{
ll now=a[i]*a[i];
for(ll j=a[i]+1;j*j-now<=L;j++) if(vis[j*j-now]) ans++;
}
printf("%d\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
input:
5 1 2 3 4 5
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 5812kb
input:
1 1
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 1ms
memory: 5812kb
input:
5 6 4 7 3 5
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 1ms
memory: 5884kb
input:
50 89 2 3 86 81 59 29 26 28 8 48 5 6 95 54 91 17 83 4 36 15 43 92 70 30 37 23 96 39 80 9 90 49 82 33 71 61 38 99 50 65 47 78 45 68 7 25 42 13 57
output:
29
result:
ok 1 number(s): "29"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
1000 662 811 263 46 591 511 230 223 628 603 716 880 187 575 701 184 505 754 130 154 367 91 704 945 171 588 19 486 34 513 622 849 629 437 776 290 743 470 587 681 723 271 879 642 77 281 71 655 365 942 809 94 266 148 146 305 198 311 788 69 343 277 887 557 169 41 784 791 451 812 932 663 594 576 487 946 ...
output:
1750
result:
ok 1 number(s): "1750"
Test #6:
score: 0
Accepted
time: 0ms
memory: 7948kb
input:
10000 2246 4941 6031 8713 4705 3744 9374 9432 2502 7080 8851 5408 4724 8905 7565 1699 6660 8959 7798 2287 4610 8806 8128 451 1355 2111 8775 4903 7517 8983 8144 2578 9565 7332 3213 4943 6520 616 2559 5573 6391 7148 5121 8395 5618 8733 6132 3717 8549 9651 1291 9462 5941 2342 9625 398 3916 8586 4290 26...
output:
23368
result:
ok 1 number(s): "23368"
Test #7:
score: -100
Wrong Answer
time: 5ms
memory: 4264kb
input:
100000 94437 49936 62522 1166 33452 90618 91436 81173 99242 37280 46125 44869 52811 45694 11550 29857 48941 56538 35057 40907 79925 70785 29658 19044 32804 11428 4127 92197 12680 61636 27200 56790 83389 80340 54411 15308 38952 78085 81397 37554 44186 33581 35662 73331 84991 32044 69012 82289 63495 6...
output:
287869
result:
wrong answer 1st numbers differ - expected: '291528', found: '287869'