爱喝奶茶的安德鲁寄了 level
获赞
53
粉丝
17
关注
9
看过 TA
664
南京工业大学
2026
C++
IP属地:湖北
暂未填写个人简介
私信
关注
Arbelite_:我的解法是考虑每个位置,当他左右元素和他不相等时再判断(101 010)然后,如果i+2没有越界,再往后考虑一个字符 如果和当前相同(1010)就把后面一位置反(1000),这样就可以同时处理两个坏串(原串假如是10101,改为11101会多处理一次,改成10001就不用处理第二次) 如果不同(1011)就考虑把当前字符置反(1111),同理 这样是防止出现额外的坏串(如10110,假如和上面的情况一样,改为10010,会造成出现新的坏串,改为11110就不会出现)
投递游酷盛世(北京)有限公司等公司8个岗位
0 点赞 评论 收藏
分享
// 小美的文本文件#include <algorithm>#include <iostream>#include <iterator>#include <stack>#include <string>using namespace std;string decode(string& s){string t;stack<char> stack;for(char c:s){if(c == 'R'){reverse(t.begin(), t.end());stack.push('R');}else if(c == 'Z'){if(!stack.empty()){char last = stack.top();stack.pop();if(last == 'R'){reverse(t.begin(),t.end());}else {if(!t.empty()){t.pop_back();}}}}else {t.push_back(c);stack.push(c);}}return t;}int main() {int n;cin >> n;cin.ignore();while (n--) {string s;getline(cin, s);cout<<decode(s)<<endl;}}// 小红的函数计算#include <iostream>using namespace std;int func(int i, int j){if(i % j == 0 && i / j != 0){return 1;}return 0;}long sumfuc(int i, int l2, int r2){int count = 0;for(int j = 1; j*j <= i; j++){if(i % j ==0){if(j > l2 && j <= r2) count++;if(j != i/j && (i/j) >= l2 && (i/j) <= r2) count++;}}return count;}int main() {int l1, r1, l2, r2;cin >> l1 >> r1 >> l2 >> r2;int sum = 0;// for (int i = l1; i <= r1; i++){//     for (int j = l2; j <= r2; j++){//         sum += func(i,j);//     }// }for (int i = l1; i <= r1; i++){sum += sumfuc(i, l2, r2);}cout << sum;}
投递美团等公司8个岗位
0 点赞 评论 收藏
分享

创作者周榜

更多
关注他的用户也关注了:
牛客网
牛客网在线编程
牛客网题解
牛客企业服务