切蛋糕 题解
Withered_sjtu · · 个人记录
切蛋糕 题解
题目描述
思路
看到数据范围,马上排除算角度暴力求解(精度不够)
我们假设
情况
情况
情况
code
#include <cstdio>
#include <algorithm>
using namespace std;
int a[5];
int main() {
freopen("cake.in", "r", stdin);
freopen("cake.out", "w", stdout);
int t;
scanf("%d", &t);
while (t--) {
scanf("%d %d %d", &a[1], &a[2], &a[3]);
sort(a + 1, a + 3 + 1);
if (a[1] == 0 && a[2] == 0) {
printf("0\n");
} else if (a[1] == 0) {
if (a[2] == a[3]) {
printf("1\n");
} else {
printf("2\n");
}
} else {
if (a[1] == a[2] || a[2] == a[3] || a[1] + a[2] == a[3]) {
printf("2\n");
} else printf("3\n");
}
}
return 0;
}