-
题意:石头剪刀布,bot有一串字符,表示他要出什么,你需要事先确定你的出招方案,然后遍历bot的字符串,从\(i\)位置开始跑一个循环,每次跑都要记录你赢的次数贡献给\(sum\),现要求\(\frac{sum}{n}\)最大,求你的最佳处找方案.
-
题解:贪心,全输出bot出招次数最多的对应即可.
-
代码:
int t; string s; map<char,int> mp; int main() { ios::sync_with_stdio(false);cin.tie(0); cin>>t; while(t--){ cin>>s; mp.clear(); for(int i=0;i<s.size();++i){ if(s[i]=='R') mp['r']++; else if(s[i]=='S') mp['s']++; else mp['p']++; } int mx=0; for(auto w:mp) mx=max(mx,w.se); if(mp['r']==mx){ for(int i=0;i<s.size();++i){ cout<<"P"; } } else if(mp['s']==mx){ for(int i=0;i<s.size();++i){ cout<<"R"; } } else{ for(int i=0;i<s.size();++i){ cout<<"S"; } } cout<<endl; } return 0; }
相关文章
- 02-26Educational Codeforces Round 89 (Rated for Div. 2)---B. Shuffle(1300分)
- 02-26【Educational Codeforces Round 61 (Rated for Div. 2) E. Knapsack】贪心+背包
- 02-26Educational Codeforces Round 91 (Rated for Div. 2) B. Universal Solution (贪心)
- 02-26Educational Codeforces Round 54 (Rated for Div. 2) Solution
- 02-26Educational Codeforces Round 63 (Rated for Div. 2) B. Game with Telephone Numbers 博弈思维+模拟+贪心思维
- 02-26Educational Codeforces Round 84 (Rated for Div. 2) B. Princesses and Princes(模拟)
- 02-26Educational Codeforces Round 47 (Rated for Div. 2) :B. Minimum Ternary String
- 02-26Educational Codeforces Round 62 (Rated for Div. 2) C 贪心 + 优先队列 + 反向处理
- 02-26Educational Codeforces Round 104 (Rated for Div. 2)B. Cat Cycle
- 02-26B. Zmei Gorynich ( Educational Codeforces Round 72 (Rated for Div. 2))