QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#333886 | #8169. R-Connected Components | 275307894a# | WA | 14ms | 3984kb | C++14 | 1.3kb | 2024-02-20 18:45:02 | 2024-02-20 18:45:03 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e6+5,M=N*N+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
}using namespace Debug;
int n;
void Solve(){
int i,j;scanf("%d",&n);
int sx=0,sy=0;ll g=0;
for(i=0;1ll*i*i<=n;i++) {
j=sqrtl(n-1ll*i*i);if(i*i+j*j!=n) continue;
if(!sx&&!sy) sx=i,sy=j;
else{
g=__gcd(g,abs(1ll*sx*j-1ll*sy*i));
}
g=__gcd(g,1ll*sx*j+1ll*sy*i);
}
if(!sx&&!sy) puts("inf");
else printf("%lld\n",g);
}
int main(){
int t=1;
scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3984kb
input:
3 1 2 3
output:
1 2 inf
result:
ok 3 tokens
Test #2:
score: 0
Accepted
time: 9ms
memory: 3980kb
input:
100 971962039 377418539 436722941 974460973 408831757 674955527 838941797 566099869 224191573 85539073 544795513 157335071 243499759 907206901 570172403 871918511 594778897 773009569 9371917 23810669 169348601 804358351 78636461 382633897 182514781 846151963 274168729 929192339 91532527 172531889 18...
output:
inf inf 1 1 1 inf 1 1 1 1 1 inf inf 1 inf inf 1 1 1 1 1 inf 1 1 1 inf 1 inf inf 1 inf inf inf inf 1 inf inf inf 1 inf inf inf inf inf 1 1 inf inf 1 1 inf inf 1 1 inf inf inf inf inf 1 1 inf inf 1 1 inf 1 1 1 1 inf inf 1 inf inf inf inf inf 1 1 1 1 inf 1 1 1 inf inf 1 inf inf 1 inf 1 inf 1 1 inf inf 1
result:
ok 100 tokens
Test #3:
score: 0
Accepted
time: 6ms
memory: 3980kb
input:
100 145332973 48696341 806778307 222052531 641666023 541840597 635341691 814013 661659811 428891707 81656189 417810353 889550023 634550447 905470561 429756883 249889429 195597113 906475553 913878767 953103803 192400903 483162293 643055177 137120771 748444841 701614733 452585411 367582519 564268909 6...
output:
1 1 inf inf inf 1 inf 1 inf inf 1 1 inf inf 1 inf 1 1 1 inf inf inf 1 1 inf 1 1 inf inf 1 inf inf 1 1 inf 1 1 1 1 inf 1 1 inf 1 inf 1 inf inf inf 1 inf 1 inf inf inf inf inf 1 inf inf 1 1 inf 1 inf 1 1 inf inf 1 inf inf inf 1 1 inf 1 1 inf inf inf inf 1 1 1 1 inf inf inf 1 1 1 inf 1 inf inf 1 1 1 inf
result:
ok 100 tokens
Test #4:
score: 0
Accepted
time: 14ms
memory: 3984kb
input:
100 999999937 999999929 999999893 999999883 999999797 999999761 999999757 999999751 999999739 999999733 999999677 999999667 999999613 999999607 999999599 999999587 999999541 999999527 999999503 999999491 999999487 999999433 999999391 999999353 999999337 999999323 999999229 999999223 999999197 999999...
output:
1 1 1 inf 1 1 1 inf inf 1 1 inf 1 inf inf inf 1 inf inf inf inf 1 inf 1 1 inf 1 inf 1 1 inf 1 inf inf 1 inf 1 inf inf inf inf inf 1 1 1 1 inf inf 1 1 1 1 inf 1 inf inf 1 1 1 1 1 inf inf inf 1 1 inf inf 1 1 1 inf 1 1 1 inf 1 inf inf 1 inf 1 1 1 inf inf inf 1 inf inf 1 1 inf inf 1 inf inf 1 inf inf
result:
ok 100 tokens
Test #5:
score: 0
Accepted
time: 6ms
memory: 3964kb
input:
100 315798823 138076441 16013527 105333433 88400579 81370909 61828003 35409677 1148723 553787863 27501853 362120687 51345997 55496489 317656091 244618859 93709579 179950021 391542071 892937473 51911033 520441661 257008447 808078441 9461321 313593769 230895449 409677377 957316117 263495411 185463989 ...
output:
inf inf inf 1 inf inf inf 1 inf inf inf inf 1 1 inf inf inf inf inf inf 1 inf inf 1 inf inf 1 1 1 inf inf inf 1 inf inf inf inf inf 1 inf inf inf 1 1 inf 1 inf inf inf inf inf 1 inf inf inf inf inf inf inf inf inf inf inf inf inf 1 inf 1 inf 1 inf inf inf 1 inf inf inf inf inf inf inf 1 inf inf inf ...
result:
ok 100 tokens
Test #6:
score: -100
Wrong Answer
time: 7ms
memory: 3940kb
input:
100 33396841 155925169 725337061 54724081 120942061 666015877 383161 901555513 883456729 24196561 743043373 12241 73396613 329229533 416642297 284838833 539493529 231009601 832841881 143815537 223173721 265406201 236882881 22071701 163814401 90810781 563712997 528397937 113699569 388557821 19246817 ...
output:
33396841 155925169 1 1 1 1 383161 1 883456729 24196561 1 1 1 1 1 1 539493529 231009601 832841881 1 223173721 1 236882881 1 163814401 1 1 1 113699569 1 1 1 1 389628121 1 1 1 1 1 1 848615161 101586241 516961 161366209 1 85137529 1 1 541911841 40436881 734789449 10004569 1 1 858665809 961 633579241 1 1...
result:
wrong answer 82nd words differ - expected: '1', found: '27277'