//第一题 #include <bits/stdc++.h> using namespace std; int getResult(string square) { int minChange = 100; int len = square.size(); if(len == 0) return 0; for (int i = 1; i < len; ++i) { int tmp = 0; for (int j = 0; j < i; ++j) { if(square[j] == 'G') tmp++; } for(int j = len - 1 ; j >= i ; --j) { if(square[j] == 'R') tmp++; } minChange = minChange > tmp ? tmp : minChange; } return minChange; } int main(){ string square; while(cin >> square) { cout << getResult(square) << endl; } return 0; } //第二题 #include <bits/stdc++.h> using namespace std; int getDigit(long long x) { int count = 0; while(x) { count++; x /= 10; } return count; } long long helper(long long x) { long long count = 0; int digit = getDigit(x); if(digit < 2) return 0; count += x/100 * 10; int y = x % 100; for (int i = 10; i <= y; ++i) { if(i/10 == i%10) count++; } return count; } long long getResult(long long l, long long r) { long long count = 0; count = helper(r) - helper(l-1); return count; } int main(){ long long l; long long r; while(cin >> l >> r) { cout << getResult(l,r) << endl; } return 0; }
点赞 评论

相关推荐

昨天 10:33
东南大学
点赞 评论 收藏
分享
程序员小白条:vibe你只要能cover住面试官问你很多深入的实现和选型方案的原因,以及怎么去检测优化效果的就行了
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务