![:evil:](./images/smilies/icon_evil.gif)
10550 - Combination Lock
Moderator: Board moderators
Remember Always turn the dial
vRemember Always turn the dial ![:evil:](./images/smilies/icon_evil.gif)
![:evil:](./images/smilies/icon_evil.gif)
-
- New poster
- Posts: 10
- Joined: Sat Aug 19, 2006 7:23 pm
- Location: bangladesh
- Contact:
as soyoja wrote:
why we should do that?
will any one explain the above condition elaborately.
altaf.
i know, in above way the problem will be accecpted but i did not understand the trik frm problem specification.The only trick of this problem is distinguish between clockwise and
counter-clocwise.
Counting angle for clockwise is (start point) - ( end point )
Counting angle for counter clockwise is (end point) - (start point )
why we should do that?
will any one explain the above condition elaborately.
altaf.
It is simple. If you want to go from 0 to 30 clockwise you have to count 90 degrees. But if you want to go 0 to 30 counter-clockwise you have to count 270 degrees. See the picture given in the problem and varify it yourself.as soyoja wrote:
Quote:
The only trick of this problem is distinguish between clockwise and
counter-clocwise.
Counting angle for clockwise is (start point) - ( end point )
Counting angle for counter clockwise is (end point) - (start point )
i know, in above way the problem will be accecpted but i did not understand the trik frm problem specification.
why we should do that?
will any one explain the above condition elaborately.
altaf.
From 0 to 0
-
- New poster
- Posts: 37
- Joined: Wed Oct 03, 2007 10:42 am
Re: 10550 - Combiantion Lock
please help me to survive from WA
anyone help me giving some special I/O I will be greatful
Tnx everyone
alamgir
anyone help me giving some special I/O I will be greatful
Code: Select all
#include<stdio.h>
int main()
{
long pos, first, sec, third, temp, sum;
while( scanf("%ld %ld %ld %ld", &pos, &first, &sec, &third) == 4 )
{
if( pos == 0 && first == 0 && sec == 0 && third == 0 ) break;
sum = 720;
if( pos > first )
{
temp = 360 - ( pos - first ) * 9 ;
}
else
{
temp = 360 - ( first - pos ) * 9 ;
}
sum += temp;
//printf("%d ", temp);
if( first > sec )
{
temp = 360 - ( first - sec ) * 9 ;
}
else
{
temp = ( sec - first ) * 9 ;
}
//printf("%d ", temp);
sum += temp;
sum += 360;
if( sec > third )
{
temp = ( ( sec - third ) ) * 9;
}
else
{
temp = 360 - ( third - sec ) * 9;
}
//printf("%d ", temp);
sum += temp;
printf("%ld\n", sum);
}
return 0;
}
alamgir
Re: 10550 - Combiantion Lock
In this problem, I found the definition of clockwise & counter-clockwise is somewhat opposite to each other! I got accepted when I reversed the actual directions!
-
- New poster
- Posts: 1
- Joined: Mon Oct 21, 2013 7:35 pm
Re: 10550 - Combiantion Lock
I have read almost all the posts about uva problem "combination lock". Actually the tric is clockwise and counter clockwise. Many are upset about this tric. I want to say our belif about clockwise and counter clockwise is right. But we does not know well the lock. If you obserb the given picture well, you will see that if you turn the central button the dial plate(the plate containing the numbers) will turn. At first like many i thought that only the central button will turn not the dial plate. In fact you have to terminate the numbers with respect to a point (upon the dial plate which is non movable). Now if you turn clockwise from 0 to 10 (90 degree) in fact you have to rotate 270 degree. Good luck. Enjoy programming
Re: 10550 - Combiantion Lock
I need some critical input and output for this problem...
Plz anyone provide me......
Plz anyone provide me......
Re: 10550 - Combiantion Lock
Here's some input / output I found useful during testing / debugging.
Input:
AC Output:
Input:
Code: Select all
2 15 28 34
25 18 1 0
19 19 19 19
33 3 36 39
39 11 22 5
2 37 18 17
0 0 0 0
Code: Select all
1746
1359
1080
1980
1584
1323
10550 - Combiantion Lock WA
What is wrong with my code? I always seem to get wrong answer and I tested some cases that give a wrong answer (the ones in the problem give me the right answer) but I have no clue as to why this is happening:
This is in C.
This is in C.
Code: Select all
#include <stdio.h>
int main ()
{
int a,b,c,d,turns=0,angle=0;
while (scanf("%d%d%d%d", &a,&b,&c,&d)!=0)
{
if(a==0&&b==0&&c==0&&d==0) break;
if(a<b)
{
turns = 40+a-b;
} else { turns += a-b; }
if(b>c)
{
turns += 40+c-b;
} else { turns += c-b; }
if (d>c)
{
turns += 40+c-d;
} else { turns += c-d; }
turns += 120;
angle = turns*9;
printf("%d\n", angle);
}
return 0;
}
Re: 10550 - Combiantion Lock
Thanks a lot for this explanation. People who have not seen such a lock or are not aware of the fact the number dial is being rotated, are frustrated to understand the calculations.Sadek romel wrote:I have read almost all the posts about uva problem "combination lock". Actually the tric is clockwise and counter clockwise. Many are upset about this tric. I want to say our belif about clockwise and counter clockwise is right. But we does not know well the lock. If you obserb the given picture well, you will see that if you turn the central button the dial plate(the plate containing the numbers) will turn. At first like many i thought that only the central button will turn not the dial plate. In fact you have to terminate the numbers with respect to a point (upon the dial plate which is non movable). Now if you turn clockwise from 0 to 10 (90 degree) in fact you have to rotate 270 degree. Good luck. Enjoy programming