File tree Expand file tree Collapse file tree 1 file changed +36
-2
lines changed Expand file tree Collapse file tree 1 file changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,6 @@ void solve(){ //要想满足每个>=2的子串都满足0数目小于1,则最
22
22
}
23
23
```
24
24
25
-
26
-
27
25
### B
28
26
29
27
> 一眼猜答案,有一些number theory的意味在里面
@@ -85,4 +83,40 @@ void solve(){
85
83
}
86
84
```
87
85
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
+
88
122
You can’t perform that action at this time.
0 commit comments