QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#54583#4184. Amusement ArcadeUsername#AC ✓3ms3688kbC++1.3kb2022-10-09 19:31:162022-10-09 19:31:17

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-09 19:31:17]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3688kb
  • [2022-10-09 19:31:16]
  • 提交

answer

#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("popcnt,abm,mmx,avx2")
#endif
#include <bits/stdc++.h>

using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
#define rep(i, l, r) for (int i = l; i < r; ++i)
using Long = long long;
using Double = double;
using vi = vector<int>;

template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#else
#define endl '\n'
#endif
  Long n;
  cin >> n;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  for (Long p = 2; p + 1 <= n; p *= 2) {
    if (popCnt(n - p - 1) <= 1) {
      cout << p + 1 << endl;
      return 0;
    }
  }
  cout << "impossible" << endl;
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3636kb

input:

7

output:

3

result:

ok 

Test #2:

score: 0
Accepted
time: 2ms
memory: 3524kb

input:

15

output:

impossible

result:

ok 

Test #3:

score: 0
Accepted
time: 2ms
memory: 3604kb

input:

19

output:

3

result:

ok 

Test #4:

score: 0
Accepted
time: 2ms
memory: 3576kb

input:

2049

output:

1025

result:

ok 

Test #5:

score: 0
Accepted
time: 2ms
memory: 3688kb

input:

32769

output:

16385

result:

ok 

Test #6:

score: 0
Accepted
time: 2ms
memory: 3556kb

input:

536870913

output:

268435457

result:

ok 

Test #7:

score: 0
Accepted
time: 2ms
memory: 3604kb

input:

35184372088833

output:

17592186044417

result:

ok 

Test #8:

score: 0
Accepted
time: 2ms
memory: 3588kb

input:

2251799813685249

output:

1125899906842625

result:

ok 

Test #9:

score: 0
Accepted
time: 1ms
memory: 3456kb

input:

576460752303423489

output:

288230376151711745

result:

ok 

Test #10:

score: 0
Accepted
time: 2ms
memory: 3584kb

input:

1027

output:

3

result:

ok 

Test #11:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

2081

output:

33

result:

ok 

Test #12:

score: 0
Accepted
time: 2ms
memory: 3524kb

input:

34393292801

output:

33554433

result:

ok 

Test #13:

score: 0
Accepted
time: 2ms
memory: 3600kb

input:

1

output:

1

result:

ok 

Test #14:

score: 0
Accepted
time: 2ms
memory: 3632kb

input:

281543696187393

output:

68719476737

result:

ok 

Test #15:

score: 0
Accepted
time: 3ms
memory: 3628kb

input:

576460752303423491

output:

3

result:

ok 

Test #16:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

576460752336977921

output:

33554433

result:

ok 

Test #17:

score: 0
Accepted
time: 2ms
memory: 3636kb

input:

576461851815051265

output:

1099511627777

result:

ok 

Test #18:

score: 0
Accepted
time: 2ms
memory: 3576kb

input:

864691128455135233

output:

288230376151711745

result:

ok 

Test #19:

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

input:

635

output:

impossible

result:

ok 

Test #20:

score: 0
Accepted
time: 3ms
memory: 3604kb

input:

4537995

output:

impossible

result:

ok 

Test #21:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

4795018843

output:

impossible

result:

ok 

Test #22:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

5268828738869

output:

impossible

result:

ok 

Test #23:

score: 0
Accepted
time: 1ms
memory: 3632kb

input:

3859135424551273

output:

impossible

result:

ok 

Test #24:

score: 0
Accepted
time: 2ms
memory: 3600kb

input:

3

output:

3

result:

ok 

Test #25:

score: 0
Accepted
time: 2ms
memory: 3664kb

input:

63913510461995523

output:

impossible

result:

ok 

Test #26:

score: 0
Accepted
time: 2ms
memory: 3528kb

input:

341683697045680425

output:

impossible

result:

ok 

Test #27:

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

input:

999999999999999999

output:

impossible

result:

ok 

Test #28:

score: 0
Accepted
time: 2ms
memory: 3584kb

input:

5

output:

3

result:

ok 

Test #29:

score: 0
Accepted
time: 2ms
memory: 3588kb

input:

9

output:

5

result:

ok 

Test #30:

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

input:

11

output:

3

result:

ok 

Test #31:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

13

output:

5

result:

ok 

Test #32:

score: 0
Accepted
time: 2ms
memory: 3632kb

input:

17

output:

9

result:

ok