92 lines
2.0 KiB
Markdown
92 lines
2.0 KiB
Markdown
|
|
## 复习提纲
|
|||
|
|
|
|||
|
|

|
|||
|
|
|
|||
|
|
以$A$为例,5进制理解为$5^0,5^1,5^2,5^3$
|
|||
|
|
$(1234)_5=1*4+3*5+2*25+1*125=194$
|
|||
|
|
$(302)_8=2*8^0+0*8^1+3*8^2=2*1+0*8+3*64=194$
|
|||
|
|
$(11000100)_2=(304)_8$ 与$(302)_8$不同,所以答案是$C$
|
|||
|
|
$(C2)_{16}=2*1+12*16=194$
|
|||
|
|
|
|||
|
|

|
|||
|
|
```cpp {.line-numbers}
|
|||
|
|
#include <bits/stdc++.h>
|
|||
|
|
using namespace std;
|
|||
|
|
|
|||
|
|
bool check(int x) {
|
|||
|
|
int sum = 0;
|
|||
|
|
while (x) {
|
|||
|
|
int a = x % 10;
|
|||
|
|
x /= 10;
|
|||
|
|
sum += a;
|
|||
|
|
}
|
|||
|
|
return sum % 2 == 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int main() {
|
|||
|
|
int n, m;
|
|||
|
|
cin >> n >> m;
|
|||
|
|
for (int i = n; i <= m; i++)
|
|||
|
|
if (check(i))
|
|||
|
|
cout << i << endl;
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|

|
|||
|
|
|
|||
|
|
```cpp {.line-numbers}
|
|||
|
|
#include <bits/stdc++.h>
|
|||
|
|
using namespace std;
|
|||
|
|
|
|||
|
|
int main() {
|
|||
|
|
string s;
|
|||
|
|
cin >> s;
|
|||
|
|
|
|||
|
|
int m;
|
|||
|
|
cin >> m;
|
|||
|
|
m--;
|
|||
|
|
|
|||
|
|
while (m--) {
|
|||
|
|
string t;
|
|||
|
|
for (int i = 0; i < s.size(); i++) {
|
|||
|
|
int c = 1;
|
|||
|
|
while (i + 1 < s.size() && s[i + 1] == s[i]) {
|
|||
|
|
c++;
|
|||
|
|
i++;
|
|||
|
|
}
|
|||
|
|
t = t + to_string(c) + s[i];
|
|||
|
|
}
|
|||
|
|
s = t;
|
|||
|
|
}
|
|||
|
|
cout << s << endl;
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
|
|||
|
|

|
|||
|
|
```cpp {.line-numbers}
|
|||
|
|
#include <bits/stdc++.h>
|
|||
|
|
using namespace std;
|
|||
|
|
int k;
|
|||
|
|
string kill(string s) {
|
|||
|
|
int p = s[s.size() - 1]; // 最后一位是默认值
|
|||
|
|
for (int i = 0; i < s.size() - 1; i++)
|
|||
|
|
if (s[i + 1] > s[i]) {
|
|||
|
|
p = i;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
string res;
|
|||
|
|
for (int i = 0; i < s.size(); i++)
|
|||
|
|
if (i != p) res += s[i];
|
|||
|
|
return res;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int main() {
|
|||
|
|
string s;
|
|||
|
|
cin >> s >> k;
|
|||
|
|
for (int i = 1; i <= k; i++) s = kill(s);
|
|||
|
|
cout << s << endl;
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
```
|