#include<bits/stdc++.h>
using namespace std;
int main()
{
int T,a,b,c,d,e=1;
char ip[40];
scanf("%d",&T);
while(T--)
{
scanf("%d.%d.%d.%d",&a,&b,&c,&d);
getchar();
scanf("%s",ip);
int sum=0,i=0;
for(int j=34; j>=27; j--)
sum += (ip[j]-48)*pow(2,i++);
if(sum != d)
{
printf("Case %d: No\n",e++);
continue;
}
sum=0;
i=0;
for(int j=25; j>=18; j--)
sum += (ip[j]-48)*pow(2,i++);
if(sum != c)
{
printf("Case %d: No\n",e++);
continue;
}
i=0;
sum=0;
for(int j=16; j>=9; j--)
sum += (ip[j]-48)*pow(2,i++);
if(sum != b)
{
printf("Case %d: No\n",e++);
continue;
}
sum=0;
i=0;
for(int j=7; j>=0; j--)
sum += (ip[j]-48)*pow(2,i++);
if(sum != a)
{
printf("Case %d: No\n",e++);
continue;
}
printf("Case %d: Yes\n",e++);
}
return 0;
}
Tuesday, July 28, 2015
1354 - IP Checking
Subscribe to:
Post Comments (Atom)
Triathlon
Triathlon - CodeChef # include < bits/stdc++.h > using namespace std ; # define fi first # define se second # define mp ...
-
# include < bits/stdc++.h > using namespace std ; int main ( ) { int T , c = 1 ; double r1 , r2 , h , p ; // ...
-
# include < bits/stdc++.h > using namespace std ; int main ( ) { long long T , S , l , n , c = 1 ; // freopen(&qu...
-
# include < bits/stdc++.h > using namespace std ; int main ( ) { int T , n , p , q , c = 1 , i , w , t , arry [ 50 ] ; ...
No comments:
Post a Comment