QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#591125#2509. Right-Coupled Numbersmrkiencf#AC ✓0ms3532kbC++20979b2024-09-26 14:20:452024-09-26 14:20:45

Judging History

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

  • [2024-09-26 14:20:45]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3532kb
  • [2024-09-26 14:20:45]
  • 提交

answer

// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#include<bits/stdc++.h>
  
using namespace std;
  
#define i64 long long
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
  
const int MAXN = 5e5 + 5;
const i64 INF = LLONG_MAX/2;
void Solve(void) {
  i64 x; cin >> x;

  auto check = [&](i64 a) {
    if (a > x/a) return false;
    if (a * a <= x && x <= a * a * 2) return true;
    return false;
  };

  for (int i = 1; i * i <= x; i ++) {
    if (x % i == 0) {
      if (check(i)) {
        cout << 1 << "\n";
        return;
      }
      if (i != x/i && check(x/i)) {
        cout << 1 << "\n";
        return;
      }
    }
  }
  cout << 0 << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(10);
  int Tests = 1; cin >> Tests; 
  while (Tests --) {
    Solve();    
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3532kb

input:

4
66
55
105
150

output:

1
0
0
1

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

1000
1
2
3
66
55
105
150
27757
14706
2141
7400
28642
6269
23121
25421
27118
21018
17067
15563
10085
29055
30316
20985
10636
3562
371
15868
20269
17415
2485
7091
4954
21331
28145
2339
4772
1769
17980
2246
7596
2869
5782
16953
3207
19832
3788
1263
26206
12365
14846
20304
23160
13287
25388
3083
16957
1...

output:

1
1
0
1
0
0
1
0
1
0
1
0
0
0
0
1
1
0
0
0
1
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
1
0
0
0
0
0
1
1
1
0
0
0
0
1
1
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
1
1
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
1
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
0
1
0
1
0
1
0
0
0
1
0
0
1
1
1
1
1
1
0
1
1
0
1
...

result:

ok 1000 lines