void swap(int &x, int &y) { int tmp = x; x = y; y = tmp; } int numberofprize(int a, int b, int c) { // write code here int res = 0; int minval = min(a, min(b, c)); if (a == minval) { if(b > c)swap(b, c); } else if (b == minval) { if (a > c) { swap(a, c); } swap(a, b); } else { if (a > b) { swap(a, b); } swap(b, c); swap(a, b); } res += a; b = b - a; c = c - a; while (c - 1 > b && b > 0 && c >= 3) { c = c - 3; b = b - 1; res += 1; } while (b >= 2) { b = b - 2; c = c - 2; res += 1; } while (c >= 5) { c = c - 5; res += 1; } return res; }
点赞 1

相关推荐

11-03 18:50
门头沟学院 Java
迷茫的大四🐶:问就是马上到,一周五天,6个月以上,全国可飞
点赞 评论 收藏
分享
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务