QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#580528 | #9378. Strange Binary | HalloWorld | AC ✓ | 3ms | 3636kb | C++20 | 1.7kb | 2024-09-21 22:17:06 | 2024-09-21 22:17:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define bit(a) (1 << a)
#define lowbit(a) (a & (-a))
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(a) cout << #a << ":" << a << endl
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef unsigned long long ull;
typedef vector<vector<int>> vvi;
typedef vector<array<int, 2>> va2;
constexpr int N = 1000010;
constexpr int INF = 2e9;
constexpr ll LLF = 2e18;
constexpr ll mod = 998244353;
constexpr int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
ll powmod(ll a,ll b,ll mod=mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll inv(ll a){return powmod(a,mod-2);}
void solve() {
ll n; cin >> n;
if (n == 0) {
cout << "NO\n";
return;
}
if (n & 1) {
cout << "YES\n";
auto k = (n - 1) / 2;
for (int i = 0; i <= 30; i++) {
if ((1ll << i) & k) {
cout << "1";
} else {
cout << "-1";
}
if ((i + 1) % 8 == 0) {
cout << "\n";
} else {
cout << " ";
}
}
cout << "1\n";
} else {
auto k = (n - 2) / 2;
if (k & 1) {
cout << "NO\n";
return;
}
cout << "YES\n";
cout << "0 ";
for (int i = 1; i <= 30; i++) {
if ((1ll << i) & k) {
cout << "1";
} else {
cout << "-1";
}
if ((i + 1) % 8 == 0) {
cout << "\n";
} else {
cout << " ";
}
}
cout << "1\n";
}
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
// cout << fixed << setprecision(10);
int testcase; cin >> testcase; for (int _ = 1; _ <= testcase; _++)
solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
3 0 3 5
output:
NO YES 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 YES -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1
result:
ok Accepted! (3 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
2 0 1073741823
output:
NO YES 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 1
result:
ok Accepted! (2 test cases)
Test #3:
score: 0
Accepted
time: 3ms
memory: 3636kb
input:
10000 324097321 555675086 304655177 991244276 9980291 383616352 1071036550 795625380 682098056 68370721 969101726 685975156 973896269 354857775 196188000 606494155 754416123 467588829 495704303 558090120 618002000 491488050 741575237 9937018 10028830 140094825 652839595 357724903 516690123 817724271...
output:
YES -1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 YES 0 1 1 -1 -1 1 1 1 -1 1 1 -1 1 1 1 -1 1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 YES -1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 NO YES 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1...
result:
ok Accepted! (10000 test cases)
Extra Test:
score: 0
Extra Test Passed