A. Only Pluses
问题:
![](https://i-blog.csdnimg.cn/direct/5740ac292bc34948ad9ab0a2b441888d.png)
思路:
放到一个数组,排序,每次最小的+1,在排序,在加1即可
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int a[4];
for(int i=0;i<3;i++) cin >>a[i];
sort(a,a+3);
for(int i=1;i<=5;i++){
a[0]++;
sort(a,a+3);
}
cout<<a[0]*a[1]*a[2]<<endl;
}
return 0;
}
B. Angry Monk
问题:
![](https://i-blog.csdnimg.cn/direct/7364fa3e10bf44108780fe8ca04aa02c.png)
思路:
先进行排序,最大的数不用管,只有这个数为1的时候才可以直接相加,大于1的数只能全都拆成1,所以看图解,以第二个样例为例子
所以2拆成1,1为1步,两个1加到最大值则是2步,一共三步,可以理解为,假设一个数为n(n!-=1),要操作完这个数的所有步骤为,首先拆分则需要n-1步,再把1加到最大值则需要n步,一共则是2n-1步所以代码就可以实现该思路
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int a[N];
int main(){
int t;
cin >> t;
int n,k;
while(t--){
cin >> n >> k;
for(int i=0;i<k;i++) cin >> a[i];
sort(a,a+k);
long long ans=0,cnt=0,f=0;
for(int i=0;i<k-1;i++){
if(a[i]==1) ans++;//遇到1直接步数++即可
else{
ans+=a[i];
ans+=a[i]-1;
}
}
cout<<ans<<endl;
}
return 0;
}
C. Gorilla and Permutation
问题:
思路:
诈骗题,注意Output说的话,答案不唯一所以直接输出其中一种就行
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
int n,m,k;
while(t--){
cin >> n >> m >> k;
for(int i=n;i>m;i--) cout<<i<<" ";
for(int i=1;i<=m;i++) cout<<i<<" ";
cout<<endl;
}
return 0;
}
D. Test of Love
问题:
思路:
直接模拟加判断就可以
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, m, k;
cin >> n >> m >> k;
string l;
cin >> l;
l += 'L';//把L当作陆地
int s = 0;
int s1 = 0;
int s2 = 0;
int f=0;
bool q = true;
for (int i = 0; i <= n; ++i) {
if (l[i] == 'L' && q) {
continue;
} else if (l[i] == 'W') {
q = false;
s1++;
} else if (l[i] == 'C') {
q = false;
s1++;
s2 = s1;
} else if (l[i] == 'L') {
q = true;
s1++;
if (s2 >= m) {
cout << "NO" << endl;
f=1;
break;
}
if (s1 > m) {
s += s1 - m;
}
s1 = 0;
s2 = 0;
}
}
if(f==0){
if (s > k ) {
cout << "NO" << endl;
} else {
cout << "YES" << endl;
}
}
}
return 0;
}