Page 2 of 2

Remember Always turn the dial

Posted: Sat Dec 10, 2005 2:23 pm
by sds1100
vRemember Always turn the dial :evil:

Posted: Fri Sep 15, 2006 12:15 am
by altaf hussain(sust_2002)
as soyoja wrote:
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.

Posted: Fri Sep 15, 2006 8:35 am
by Towhid
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.
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.

Re: 10550 - Combiantion Lock

Posted: Fri May 22, 2009 8:29 am
by alamgir kabir
please help me to survive from WA
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;
}
Tnx everyone
alamgir

Re: 10550 - Combiantion Lock

Posted: Wed Jul 06, 2011 3:56 pm
by pseudonym
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!

Re: 10550 - Combiantion Lock

Posted: Mon Oct 21, 2013 8:07 pm
by Sadek romel
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

Posted: Tue Dec 10, 2013 1:56 pm
by jokerz
I need some critical input and output for this problem...
Plz anyone provide me......

Re: 10550 - Combiantion Lock

Posted: Fri Apr 04, 2014 8:38 am
by uDebug
Here's some input / output I found useful during testing / debugging.

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
AC Output:

Code: Select all

1746
1359
1080
1980
1584
1323

10550 - Combiantion Lock WA

Posted: Tue Sep 29, 2015 9:41 pm
by KoltPenny
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.

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

Posted: Wed Jun 22, 2016 9:58 pm
by mdtareque
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
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.