Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
27694 | 唐心 | 石头剪刀布 | C++ | Accepted | 2 MS | 736 KB | 979 | 2022-06-09 20:27:39 |
#include<iostream> using namespace std; int main() { int n,k; int r,s,c,num = 0; char str[100],temp[100]; cin >>n>>k; cin >>r>>s>>c; cin >>str; for(int i = 0; i < n;i++) { if(str[i]=='r' && i<k) { num += 6; temp[i] = 'c'; } else if(str[i]=='s' && i<k) { num += 8; temp[i] = 'r'; } else if(str[i]=='c' && i<k) { num += 7; temp[i] = 's'; } if(i>=k) { if(str[i]=='r' && 'c'!=temp[i-k]) { num += 6; temp[i] = 'c'; // cout<<str[i]<<" "<<temp[i-k]<<endl; } else if(str[i]=='s' && 'r'!=temp[i-k]) { num += 8; temp[i] = 'r'; // cout<<str[i]<<" "<<temp[i-k]<<endl; } else if(str[i]=='c' && 's'!=temp[i-k]) { num += 7; temp[i] = 's'; // cout<<str[i]<<" "<<temp[i-k]<<endl; } else { temp[i] = str[i]; // cout<<str[i]<<" "<<temp[i-k]<<endl; } } // cout << num<<endl; } cout << num<<endl; }