Skip to content

Commit 13d6b78

Browse files
committed
update codeforces779 div2.md
1 parent d1ae58c commit 13d6b78

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

codeforces/779/codeforces779 div2.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ void solve(){ //要想满足每个>=2的子串都满足0数目小于1,则最
2222
}
2323
```
2424

25-
26-
2725
### B
2826

2927
> 一眼猜答案,有一些number theory的意味在里面
@@ -85,4 +83,40 @@ void solve(){
8583
}
8684
```
8785

86+
### D1
87+
88+
由异或的性质,如果说&x之前所有数的某一位为cnt[i]个,那么异或1之后必定不为cnt[i]个,因此,如果说某些位出现次数不为0并且异或后不为cnt[i],则肯定出现过。
89+
90+
```cpp
91+
void solve(){
92+
vector <int> cnt(20);
93+
int l, r;
94+
cin >> l >> r;
95+
for(int i = 0; i <= r; i++){
96+
for(int j = 17; j >= 0; j--){
97+
if((i >> j & 1)){
98+
cnt[j]++;
99+
}
100+
}
101+
}
102+
int a;
103+
vector <int> cnt1(20);
104+
for(int i = 0; i <= r; i++){
105+
cin >> a;
106+
for(int j = 17; j >= 0; j--){
107+
if((a >> j & 1) == 1) cnt1[j]++;
108+
}
109+
}
110+
int ans = 0;
111+
for(int i = 0; i <= 17; i++){
112+
//cout << cnt1[i] << endl;
113+
if(cnt1[i] == r + 1){
114+
ans |= 1 << i;
115+
}
116+
else if(cnt1[i] && cnt[i] != cnt1[i]) ans |= 1 << i;
117+
}
118+
cout << ans << endl;
119+
}
120+
```
121+
88122

0 commit comments

Comments
 (0)