QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#745070 | #8169. R-Connected Components | ucup-team3646 | WA | 4ms | 3484kb | C++20 | 1.4kb | 2024-11-14 03:03:35 | 2024-11-14 03:03:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, l, r) for (ll i = l; i < r; i++)
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
/* ---- */
#define all(A) A.begin(), A.end()
#define elif else if
using pii = pair<ll, ll>;
bool chmin(auto &a, const auto &b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto &a, const auto &b) { return a < b ? a = b, 1 : 0; }
struct IOSetup {
IOSetup() {
cin.tie(0);
ios::sync_with_stdio(0);
}
} iosetup;
template <class T>
void print(vector<T> a) {
for (auto x : a) cerr << x << ' ';
cerr << endl;
}
void print(auto x) { cerr << x << endl; }
template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
cerr << head << ' ';
print(forward<Tail>(tail)...);
}
const ll mod = 998244353;
void solve(){
ll n;
cin>>n;
vector<pair<ll,ll>>p;
ll j=sqrtl(n);
for(ll i=0;i*i<=n;i++){
while(i*i+j*j>n)j--;
if(i*i+j*j==n){
p.push_back({i,j});
}
}
if(p.size()==0){
cout<<"inf"<<endl;
return;
}
ll g=0;
for(auto [x,y]:p){
g=__gcd(x,g);
g=__gcd(y,g);
}
bool flag=true;
for(auto [x,y]:p){
if(((x/g)+(y/g)%2)==1){
flag=false;
}
}
if(flag)cout<<g*g*2<<endl;
else cout<<g*g<<endl;
}
int main(){
int T;
cin>>T;
rep(i,T)solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3468kb
input:
3 1 2 3
output:
1 2 inf
result:
ok 3 tokens
Test #2:
score: -100
Wrong Answer
time: 4ms
memory: 3484kb
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 2 2 2 inf 2 2 2 2 2 inf inf 2 inf inf 2 2 2 2 2 inf 2 2 2 inf 2 inf inf 2 inf inf inf inf 2 inf inf inf 2 inf inf inf inf inf 2 2 inf inf 2 2 inf inf 2 2 inf inf inf inf inf 2 2 inf inf 2 2 inf 2 2 2 2 inf inf 2 inf inf inf inf inf 2 2 2 2 inf 2 2 2 inf inf 2 inf inf 2 inf 2 inf 2 2 inf inf 2
result:
wrong answer 3rd words differ - expected: '1', found: '2'