DAY 6
0

## Day6 第二十六題~第三十題

### 第二十六題 UVa11364

#include<iostream>
using namespace std;

int main()
{
int tc;
cin>>tc;
while(tc--)
{
int dot,point,big=0,small=99;
cin>>dot;
while(dot--)
{
cin>>point;
if(big<point)
big=point;
if(small>point)
small=point;
}
cout<<(big-small)*2<<endl;
}
}

### 第二十七題 UVa11369

#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
int tc;
cin>>tc;
while(tc--)
{
int thing,ans=0;
cin>>thing;
int money[thing];
for(int i=0;i<thing;i++)
cin>>money[i];
sort(money,money+thing,greater<int>());
for(int i=2;i<thing;i+=3)
ans+=money[i];
cout<<ans<<endl;
}
}

### 第二十八題 UVa11398

#include<iostream>
#include<string>
using namespace std;

int btod(string number)
{
int num=0;
for(int i=0;i<number.length();i++)
{
num=num*2+(number[i]-48);
}
return num;
}

int main()
{
string c,binary;
char flag;
while(cin>>c)
{
if(c=="~")
break;
else if(c=="#")
{
cout<<btod(binary)<<endl;
binary="";
}
else if(c=="0")
flag='1';
else if(c=="00")
flag='0';
else
{
int time=c.length()-2;
while(time--)
binary+=flag;
}
}
}

### 第二十九題 UVa11479

#include<iostream>
#include<cmath>
using namespace std;

int main()
{
int tc;
cin>>tc;
long long a,b,c;
for(int test=1;test<=tc;test++)
{
cin>>a>>b>>c;
cout<<"Case "<<test<<": ";
if(a+b<=c||b+c<=a||a+c<=b||a<=0||b<=0||c<=0)
cout<<"Invalid"<<endl;
else if(a==b&&b==c)
cout<<"Equilateral"<<endl;
else if(a==b||a==c||b==c)
cout<<"Isosceles"<<endl;
else
cout<<"Scalene"<<endl;
}
}

### 第三十題 UVa11494

#include<iostream>
#include<cmath>
using namespace std;

int main()
{
int x1,y1,x2,y2;
while(cin>>x1>>y1>>x2>>y2)
{
if(x1==0&&x2==0&&y1==0&&y2==0)
break;
if(x1==x2&&y1==y2)
cout<<0<<endl;
else if(x1==x2||y1==y2||abs(x1-x2)==abs(y1-y2))
cout<<1<<endl;
else
cout<<2<<endl;
}
}