10550 - Combination Lock

All about problems in Volume 105. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

sds1100
Learning poster
Posts: 95
Joined: Sat Dec 10, 2005 2:09 pm

Remember Always turn the dial

Post by sds1100 »

vRemember Always turn the dial :evil:
altaf hussain(sust_2002)
New poster
Posts: 10
Joined: Sat Aug 19, 2006 7:23 pm
Location: bangladesh
Contact:

Post 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.
Towhid
New poster
Posts: 38
Joined: Wed May 28, 2003 5:30 pm
Location: Bangladesh
Contact:

Post 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.
From 0 to 0
alamgir kabir
New poster
Posts: 37
Joined: Wed Oct 03, 2007 10:42 am

Re: 10550 - Combiantion Lock

Post 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
pseudonym
New poster
Posts: 1
Joined: Wed Jul 06, 2011 3:51 pm

Re: 10550 - Combiantion Lock

Post 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!
Sadek romel
New poster
Posts: 1
Joined: Mon Oct 21, 2013 7:35 pm

Re: 10550 - Combiantion Lock

Post 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
jokerz
New poster
Posts: 8
Joined: Tue Nov 05, 2013 10:24 am

Re: 10550 - Combiantion Lock

Post by jokerz »

I need some critical input and output for this problem...
Plz anyone provide me......
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 10550 - Combiantion Lock

Post 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
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.
KoltPenny
New poster
Posts: 1
Joined: Tue Sep 29, 2015 6:05 pm

10550 - Combiantion Lock WA

Post 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;
}
mdtareque
New poster
Posts: 1
Joined: Wed Jun 22, 2016 9:50 pm

Re: 10550 - Combiantion Lock

Post 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.
Post Reply

Return to “Volume 105 (10500-10599)”