题解:P10993 【MX-J3-T0】37
本题考点:to_string、unique 和 string::erase 的熟练运用。
我们先将 to_string 函数将
我们再执行语句 s.erase(unique(s.begin(), s.end()), s.end()); 就可以完成去重操作了。其中,unique 是去重函数,返回去重后的尾迭代器;erase(start, end) 表示删除 start 到 end 前的所有元素。因此,这段语句可以起到去重的作用。
参考代码如下:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
int x;
cin >> x;
x *= 37;
string ans = to_string(x);
ans.erase(unique(ans.begin(), ans.end()), ans.end());
cout << ((int)ans.size() == 1 ? "Yes" : "No");
}