222 字
1 分钟
牛客周赛 115 题解
A
#include <bits/stdc++.h>
using namespace std;
int main(){ string s; cin >> s; if(s[0] == 'R'){ cout << 0 << endl; return 0; } int a, b; cin >> a >> b; cout << ((a-1)*20+b) << endl; return 0;}B
稍微观察一下就行
#include <bits/stdc++.h>
using namespace std;
int main(){ int n2[11]; n2[0] = 1; for(int i = 1; i <= 10; i++){ n2[i] = n2[i-1]*2; } int n; cin >> n; while(n--){ int a, k; cin >> a >> k; cout << (n2[k]*a) << endl; } return 0;}C
不要被题面蒙蔽双眼
不要被题面蒙蔽双眼
不要被题面蒙蔽双眼
重要的话说三遍,相信自己的判断是对的。
去您的结果可能很大。
遍历一次就行
#include <bits/stdc++.h>
using namespace std;
int main(){ int T; cin >> T; while(T--){ int n; cin >> n; string s; cin >> s; int ret = 0; bool a = true; bool l = a; for(int i = n-2; i >= -1; i--){ if(l){ l = s[i+1] == '1'; }else{ l = s[i+1] == '0'; } } if(l)ret += 2; cout << ret << endl; } return 0;}