Problem Type : Ad hoc
#include<bits/stdc++.h>
int main()
{
int a,b,c,d,sum,p,q,r,x;
while(scanf("%d %d %d %d",&a ,&b,&c,&d)==4)
{
if(a==0 && b==0 && c==0 && d==0)
break;
p=a;
q=b;
r=c;
x=d;
if(a<b)
{
p=a+40;
}
sum=(p-q)*9;
if(c<b)
{
r=r+40;
}
sum+=abs(r-q)*9;
r=c;
if(c<d)
{
r=r+40;
}
sum+=abs(r-x)*9;
//printf("%d\n",sum);
printf("%d\n",sum+1080);
}
}
#include<bits/stdc++.h>
int main()
{
int a,b,c,d,sum,p,q,r,x;
while(scanf("%d %d %d %d",&a ,&b,&c,&d)==4)
{
if(a==0 && b==0 && c==0 && d==0)
break;
p=a;
q=b;
r=c;
x=d;
if(a<b)
{
p=a+40;
}
sum=(p-q)*9;
if(c<b)
{
r=r+40;
}
sum+=abs(r-q)*9;
r=c;
if(c<d)
{
r=r+40;
}
sum+=abs(r-x)*9;
//printf("%d\n",sum);
printf("%d\n",sum+1080);
}
}
No comments:
Post a Comment