Tired of boring office work, Denis decided to open a fast food restaurant.

On the first day he made aa portions of dumplings, bb portions of cranberry juice and cc pancakes with condensed milk.

The peculiarity of Denis's restaurant is the procedure of ordering food. For each visitor Denis himself chooses a set of dishes that this visitor will receive. When doing so, Denis is guided by the following rules:

  • every visitor should receive at least one dish (dumplings, cranberry juice, pancakes with condensed milk are all considered to be dishes);
  • each visitor should receive no more than one portion of dumplings, no more than one portion of cranberry juice and no more than one pancake with condensed milk;
  • all visitors should receive different sets of dishes.

What is the maximum number of visitors Denis can feed?

Input

The first line contains an integer tt (1≤t≤5001≤t≤500) — the number of test cases to solve.

Each of the remaining tt lines contains integers aa, bb and cc (0≤a,b,c≤100≤a,b,c≤10) — the number of portions of dumplings, the number of portions of cranberry juice and the number of condensed milk pancakes Denis made.

Output

For each test case print a single integer — the maximum number of visitors Denis can feed.

Example
Input

 
7
1 2 1
0 0 0
9 1 7
2 2 3
2 3 2
3 2 2
4 4 4
Output

 
3
0
4
5
5
5
7
思维题,需要贪心一下。可以想到最多只有其中配餐情况。先把输入的三个数sort一下。先考虑只发一种的情况,分别判断三个数是否大于0,是的话ans++,原数--。然后判断两种的情况,这里要注意,要贪心地优先拿数量最多的菜和较少的两种搭配(顺序无所谓) 可以考虑一个样例的2 2 3.然后三种菜全选的话直接判断能不能满足就行。
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int a[];
cin>>a[]>>a[]>>a[];
sort(a,a+);
int cnt=;
if(a[])cnt++,a[]--;
if(a[])cnt++,a[]--;
if(a[])cnt++,a[]--;
if(a[]>&&a[]>)cnt++,a[]--,a[]--;//贪心分配
if(a[]>&&a[]>)cnt++,a[]--,a[]--;
if(a[]>&&a[]>)cnt++,a[]--,a[]--;
if(a[]>&&a[]>&&a[]>)cnt++;
cout<<cnt<<endl;
}
return ;
}

最新文章

  1. 利用Python进行数据分析(7) pandas基础: Series和DataFrame的简单介绍
  2. [LeetCode] Repeated DNA Sequences 求重复的DNA序列
  3. java:警告:[unchecked] 对作为普通类型 java.util.HashMap 的成员的put(K,V) 的调用未经检查
  4. Java代码执行顺序(静态变量,非静态变量,静态代码块,代码块,构造函数)加载顺序
  5. alloc
  6. pace.js和NProgress.js两个加载进度插件的一点小总结
  7. opencv 3.0 DPM Cascade 检测 (附带TBB和openMP加速)
  8. bzoj列表3
  9. 驱动读写进程内存R3,R0通信
  10. [Cycle.js] Fine-grained control over the DOM Source
  11. 逗号&quot; , &quot;表达式
  12. NYOJ--513--A+B Problem IV(大数)
  13. js 在遍历时只会显示最后一个遍历到的结果
  14. Web前端 web的学习之路
  15. duilib
  16. mysql 提高一 动态sql 传变量
  17. FastDFS安装与使用
  18. urllib.parse.quote
  19. Java程序员面试中的多线程问题1
  20. yii2入门安装 Windows7+wamp+yii2

热门文章

  1. 2019牛客训练赛第七场 C Governing sand 权值线段树+贪心
  2. linux交互执行命令,expect
  3. 记录 shell学习过程(1) 超简单的面向过程的2个shell 分区以及创建lvm
  4. laravel Type error: Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request
  5. Linux命令 sleep 延迟
  6. (转)Hadoop 简介
  7. 【模板】裸SPFA
  8. 剑指offer 面试题. 按之字形顺序打印二叉树
  9. sql server和eclipse连接代码
  10. (GHRD)HPS