CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • February CookOff
    • February Long Contest
    • January CookOff
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Ranks
    • Tutorials
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » Craft 2010 » Hardware Store

Hardware Store

Problem code: CRAFT05

  • All Submissions

Aman has a hardware store in Una. One day when he went down to the store room to fetch a box of nails. He found that the price tag had faded out. The first and the last digits of the price were not readable. Although, the number of nails in the box could be read clearly. The box read,
72 nails, Rs. _679_
What were the two faded digits, and what was the price of one nail?
Aman s friend Arnab has great knowledge of computer programming. So Aman approached him. He wants him write a program that solves the general version of the above problem:
N nails, Rs. _XYZ_
The total number of nails, N, is between 1 and 99, including both. The total price originally consisted of five digits, but we can see only the three digits in the middle. We assume that the first digit is nonzero, that the price of one nail is an integer number of rupees, and that all the nails cost the same price. Given N, X, Y, and Z, write a program that guesses the two faded digits and the original price. In case that there is more than one candidate for the original price, the output should be the most expensive one. That is, the program is to report the two faded digits and the maximum price per nail for the nails

Input

The input consists of T test cases. The number of test cases ( T ) is given on the first line of the input file. The first line of each test case contains an integer N (0 < N < 100), which represents the number of nails. In the following line, there are the three decimal digits X, Y, and Z, separated by a space, of the original price $_XYZ_.

Output

For each test case, your program has to do the following. For a test case, there may be more than one candidate for the original price or there is none. In the latter case your program is to report 0. therwise, if there is more than one candidate for the original price, the program is to report the two faded digits and the maximum price per turkey for the turkeys. The following shows sample input and output for three test cases.

Example

Input:
3
72
6 7 9
5
2 3 7
78
0 0 5


Output:
3 2 511
9 5 18475
0


Date: 2010-03-04
Time limit: 20s
Source limit: 50000
Languages: C C99 strict C++ 4.0.0-8 C++ 4.3.2 PAS gpc PAS fpc JAVA NICE JAR C# C#2 NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE PHP SCM guile SCM qobi LISP sbcl LISP clisp SCALA HASK ERL CAML CLPS PRLG WSPC BF ICK JS


  • Submit

Comments

  • Login or Register to post a comment.

The test data is incorrect.

rahulakaneo @ 10 Mar 2010 06:16 PM

The test data is incorrect. This is originally an ACM Problem from seoul regionals and is available at many ACM ICPC online judges for testing. I got my solution accepted at 2 of these and got WA in here.

@Rahul Gulati could you pls

mandarjoshi @ 10 Mar 2010 06:27 PM
@Rahul Gulati could you pls provide a link to the problem on one of the acm judges?

Links: 1.

rahulakaneo @ 10 Mar 2010 10:06 PM

Links:

1. http://acm.zju.edu.cn:8081/onlinejudge/showProblem.do?problemCode=2679

2. http://acmicpc-live-archive.uva.es/nuevoportal/data/problem.php?p=2806

 

Are you an admin by the way?

no, i'm not. thanks for those

mandarjoshi @ 10 Mar 2010 10:29 PM
no, i'm not. thanks for those links!

why am i gettign the

dejavu @ 11 Mar 2010 02:28 AM

why am i gettign the following error:- when i'm tryign submit a cpp code?

You can't submit in this language for this problem. Try link.

@Ankit Same error here as

hellboy47 @ 11 Mar 2010 02:32 AM

@Ankit Same error here as well..

& does neone even check these comments?

You might be submitting a cpp

amanatadmin @ 11 Mar 2010 10:43 AM

You might be submitting a cpp file by using some otjer compiler

@jaireet Please select the

amanatadmin @ 11 Mar 2010 10:44 AM

@jaireet

Please select the approprite compiler as well when u are submitting the solution

hey rahul i my code was

kirankelageri @ 11 Mar 2010 10:58 AM

hey rahul i my code was accepted by both the links prvided by you, but here i am getting wrong answere

Hi admin team, I am trying to

kirankelageri @ 11 Mar 2010 11:25 AM

Hi admin team, I am trying to submit once after pasting the code in given space, but code is not being run

i.e. neither it is running nor throwing ny kind of errors. This is happeing only for this problem

i am getting this error You

gaurav17 @ 11 Mar 2010 01:04 PM

i am getting this error

You can't submit in this language for this problem. Try link.

Same erorr.

kirankelageri @ 11 Mar 2010 03:37 PM

Same erorr.

I am also getting same

ron @ 11 Mar 2010 03:49 PM

I am also getting same error.

Admin needs to check it once.

yup..getting same error

alok @ 11 Mar 2010 05:11 PM

yup..getting same error "Can't submit in this language, try link"

@aman : thats not the

dejavu @ 11 Mar 2010 05:26 PM

@aman : thats not the problem...error persists... but otherwis ei got successful submission in the missile targetting problem...

@admin: any email id or alternate way for submitting the solution??

@lucky :yes me getting the same error...

if wrong complier was the

dejavu @ 11 Mar 2010 05:30 PM

if wrong complier was the case , it wud show a compile error (still accept the code) here the bug is something else... there has been no recent activity(except for the 7 submissions) in this problem due to the error i guess

I am also getting the same

mcsharma1990 @ 11 Mar 2010 06:15 PM

I am also getting the same error

@Ankit Malpani:Send ur code

amanatadmin @ 11 Mar 2010 07:18 PM

@Ankit Malpani:Send ur code at teamcse.nimbus@gmail.com. I'll check it personally but the final submission have to be done at codechef.com only

@Aman - Guess more than two

hellboy47 @ 11 Mar 2010 07:49 PM

@Aman - Guess more than two means there is definitely something wrong. Check it out asap.

@Aman You can't submit in

vish @ 11 Mar 2010 10:36 PM

@Aman

You can't submit in this language for this problem. Try link.

I'm getting this error while submitting..............

same error here too..........

ravishukla @ 11 Mar 2010 11:21 PM

same error here too..........

The problem hes been sorted

amanatadmin @ 12 Mar 2010 01:08 AM

The problem hes been sorted out.

Sorry for the inconvenience.

made it

mohan krishna @ 13 Mar 2010 10:21 AM

made it

Hi ! I'm getting a Runtime

linkid @ 13 Mar 2010 05:09 PM

Hi !

I'm getting a Runtime Error (NZEC) in Python and I don't know why. So, what are the main reasons in Python in general ?

Thanks.

@ François Magimel try

mcsharma1990 @ 13 Mar 2010 06:05 PM

@ François Magimel

try int(raw_input()) rather than int(input())

@ Mahesh Chandra Sharma: I'm

linkid @ 13 Mar 2010 06:47 PM

@ Mahesh Chandra Sharma:

I'm already using int(raw_input()) but it's not working...

So, this contest is finished.

linkid @ 13 Mar 2010 07:13 PM

So, this contest is finished. Can you help me with this runtime error (NZEC) in Python ?

Thanks.

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com