#include<iostream>
using namespace std;
int main(){
int s1, s2, s3;
cin >> s1 >> s2 >> s3;
int a[81] = { 0 },sum=0;//?
for (int i = 1; i <= s1; ++i) {
for (int j = 1; j <= s2; ++j) {
for (int k = 1; k <= s3; ++k) {
sum = i + j + k; a[sum]++;
}
}
}int i,j,max=3;
for (i = 3; i <= s1 + s2 + s3; ++i) {
// int max = 3;
if (max < a[i]) {
max = a[i]; j = i;
}
}
cout << i<<endl<<j;
return 0;
}
#include<iostream>
using namespace std;
//P2911洛谷 本来写出来着。但没啥新意。就
/*
求出哪个所有“三个面上的数字的和”出现得最频繁。如果有很多个和出现的概率相同,那么只需要输出最小的那个。
数据范围:2<=s1<=20;2<=s2<=20;2<=s<=40
*/
int main() {
int s1, s2, s3, a[81]{0};
cin >> s1 >> s2 >> s3;
int s[3]{ 0 }, min = s1;
if (s1 != s2 && s1 != s3 && s2 != s3) {//输入的三个数各不相同时。找出最大于s【2】,最小于s【0】;(排序)
int max, min;
max = s1 > s2 ? (s1 > s3 ? s1 : s3) : (s2 > s3 ? s2 : s3);
min = s1 < s2 ? (s1 < s3 ? s1 : s3) : (s2 < s3 ? s2 : s3);
s[0] = min; s[2] = max;
int sum = 0;//我在想答案肯定出现在s【0】*2+1 到s【2】*2+1之间。。就这样
for (int k = 1; k <= s[1]; ++k) {
for (int j = s[0]; j <= s[1]; ++j) {
sum = s[0] + j + k; a[sum]++;
}
}int max1 = 2 * s[0] + 1, j = 0;
for (int i = max1; i < 81; ++i) {
if (max1 < a[i])j = i;
}
cout << j;
}//else 是至少有两个相同。
else {
if (s1 == s2)cout << 2 * s1 + 1;
else {
if (s1 == s3)cout << 2 * s1 + 1;
else if (s2 == s3)cout << s2 * 2 + 1;
}
}return 0;
}
辛苦“Ctrl”君了、、:)