QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#88772 | #4810. Add One | Olegpresnyakov | WA | 2ms | 3476kb | C++14 | 2.1kb | 2023-03-17 09:37:50 | 2023-03-17 09:37:51 |
Judging History
answer
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <fstream>
#include<time.h>
#include <unordered_map>
#include <cstdlib>
#include <string.h>
#include <bitset>
#include <unordered_set>
#include <cstdlib>
#include <cassert>
#include <queue>
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
#define rep1n(i, n) for(int i = 1; i <= (n); ++i)
#define repr(i, n) for(int i = (n) - 1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (int)(a.size())
#define each(x, a) for(auto &x : a)
#define ar array
#define int long long
using namespace std;
int Bit(int mask, int b) { return (mask >> b) & 1ll; }
template<class T> bool ckmin(T &a, const T &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template<class T> bool ckmax(T &a, const T &b) {
if (b > a) {
a = b;
return true;
}
return false;
}
//__builtin_popcount = int
//__builtin_popcountl = long int
//__builtin_popcountll = long long
void solve(){
int n;
cin >> n;
vector<int> a(n);
for(int i = 0; i < n; ++i){
cin >> a[i];
}
vector<int> b(61, 0);
for(int i = 0; i < n; ++i){
for(int bit = 0; bit < 61; ++bit){
if(Bit(a[i], bit)){
b[bit]++;
}
}
}
int index = -1;
for(int i = 0; i < 61; ++i){
if(b[i] == 0){
index = i;
break;
}
}
for(int i = 0; i < index; ++i){
b[i]--;
}
b[index]++;
int ans = 0;
for(int i = 0; i < 61; ++i){
ans += ((1ll << i) * (b[i] % 2));
}
cout << ans << "\n";
}
signed main(){
ios_base::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3324kb
input:
4 1 2 1 2
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3472kb
input:
5 1 2 3 4 5
output:
14
result:
ok 1 number(s): "14"
Test #3:
score: 0
Accepted
time: 2ms
memory: 3364kb
input:
6 1 2 4 7 15 31
output:
47
result:
ok 1 number(s): "47"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3328kb
input:
5 41 40 50 11 36
output:
99
result:
ok 1 number(s): "99"
Test #5:
score: 0
Accepted
time: 2ms
memory: 3476kb
input:
6 10 40 60 2 44 47
output:
96
result:
ok 1 number(s): "96"
Test #6:
score: 0
Accepted
time: 2ms
memory: 3472kb
input:
6 46 25 39 47 23 60
output:
107
result:
ok 1 number(s): "107"
Test #7:
score: -100
Wrong Answer
time: 2ms
memory: 3476kb
input:
6 56 90 61 63 56 23
output:
176
result:
wrong answer 1st numbers differ - expected: '112', found: '176'