T1
注意到你们都会直接计算 ,这里来一种正推的枚举方法,因为 ,所以 ,暴力枚举就能过。
for(int s = 1; s <= 100; s++)
if(k * s + k * s + k == m) cout << s << "\n"; T2
注意到这题的 ,可以直接枚举你分别买了几根棒棒糖和软糖,判断钱够不够买,然后选买的最多的。
for(int i = 0; i <= a; i++)
for(int j = 0; j <= b; j++)
if(i * x + j * y <= m)
ans = max(ans, i + j);T3
注意到有 种情况,
统计每个数出现次数,考虑一下零界点,然后就可以实现。
while(n--) cin >> a, t[a]++;
if(x + y <= 1000 && t[x + y]) ans1 += t[x + y], ans2 = max(ans2, x + y), t[x + y] = 0;
if(x * y <= 1000 && t[x * y]) ans1 += t[x * y], ans2 = max(ans2, x * y), t[x * y] = 0;
if(x - y > 0 && t[x - y]) ans1 += t[x - y], ans2 = max(ans2, x - y), t[x - y] = 0;
if(y - x > 0 && t[y - x]) ans1 += t[y - x], ans2 = max(ans2, y - x), t[y - x] = 0;
if(x % y == 0 && t[x / y]) ans1 += t[x / y], ans2 = max(ans2, x / y), t[x / y] = 0;
if(y % x == 0 && t[y / x]) ans1 += t[y / x], ans2 = max(ans2, y / x), t[y / x] = 0;T4
简单模拟就可以。
T5
这题看懂题目就很简单,因为有 ,所以直接枚举 ,然后按照题目的流程模拟判断是否能变成输入的 。
for(int i = 10; i <= 99; i++)
for(int j = 10; j <= 99; j++){
x = i, y = j;
..........\\ 模拟题目过程
if(x == xx && y == yy) ans++;
}T6
这题实质上就是就是看每个字母的前一个是不是元音字母,如果是就大写输出。
while(n--){
cin >> s;
cout << char(s[0] - 'a' + 'A');
for(int i = 1; i < s.size(); i++)
if(s[i - 1] == ......) //判断是不是元音字母
cout << char(s[i] - 'a' + 'A');
cout << "\n";
}