12602 - Nice Licence Plates

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

Moderator: Board moderators

Post Reply
alimbubt
New poster
Posts: 39
Joined: Tue Aug 07, 2012 10:40 pm
Location: BUBT,Dhaka, Bangladesh
Contact:

12602 - Nice Licence Plates

Post by alimbubt » Tue Mar 26, 2013 8:34 pm

Input:

Code: Select all

10
ABC-0123
AAA-9999
FVB-7651
TGH-0001
ILL-8999
LOL-0012
ABA-0123
AMD-9786
KKK-6666
AAA-0000
Output:

Code: Select all

nice
not nice
not nice
not nice
not nice
not nice
nice
not nice
not nice
nice
Give me six hours to chop down a tree and I will spend the first four sharpening the axe...(BUBT ILLUSION)
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 12602 - Nice Licence Plates

Post by uDebug » Fri Feb 21, 2014 8:52 am

Here's some input / output that I found useful during testing / debugging.

Input:

Code: Select all

9
BBZ-0627
BBZ-0626
BBZ-0827
BBZ-0828
KHI-6950
KHI-7051
KHI-7050
KHI-6850
KHI-6849
AC Output:

Code: Select all

nice
not nice
nice
not nice
nice
not nice
nice
nice
not nice
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

ashek.rahman
New poster
Posts: 8
Joined: Mon Mar 10, 2014 8:18 am

Re: 12602 - Nice Licence Plates

Post by ashek.rahman » Thu Mar 20, 2014 1:06 pm

What is the problem in my code? I got wrong answer. Please help.

Code: Select all

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

using namespace std;

int main()
{
    int n, fpn, spn;
    string s;
    cin >> n;
    getchar();
    for (int i=0; i<n; i++){
        getline(cin, s, '-');
        fpn = (s[0]-65)*52+(s[1]-65)*26+(s[2]-65);
        getline(cin, s, '\n');
        spn = atoi(s.c_str());
        if (abs(fpn-spn)<=100)
            cout << "nice" << endl;
        else
            cout << "not nice" << endl;
        //cout << fpn << " " << spn << endl;
    }
    return 0;
}

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 12602 - Nice Licence Plates

Post by uDebug » Thu Mar 20, 2014 1:12 pm

ashek.rahman wrote:What is the problem in my code? I got wrong answer. Please help.
How about at least trying the test cases posted right above your post and seeing what happens?

It's probably not a good idea to use a single "getchar" after using a "cin" and expect that to be a newline. Something like this is mostly a better bet

Code: Select all

/* Read in the number of plates */
scanf("%d", &numberOfPlates);
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

ashek.rahman
New poster
Posts: 8
Joined: Mon Mar 10, 2014 8:18 am

Re: 12602 - Nice Licence Plates

Post by ashek.rahman » Thu Mar 20, 2014 2:22 pm

Removed. AC :)
Last edited by ashek.rahman on Mon Mar 24, 2014 7:41 am, edited 1 time in total.

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 12602 - Nice Licence Plates

Post by uDebug » Thu Mar 20, 2014 2:37 pm

ashek.rahman wrote:@v1n1t...For your given testcase the following output is shown:
Please use code tags when sharing input / output. It makes things easier to read.
I think your answer is wrong. Because BBZ = 103 and abs(103,627)=524>100. So I think it is "not nice".
Next, BBZ does not equal 103. Read the problem statement more carefully.

Here's a hint: What does the binary number

1011

equal in decimal? How do you proceed to expand it out? Try applying those same principals to this problem - except bear in mind that you're now in Base 26 - not Base 2.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

ashek.rahman
New poster
Posts: 8
Joined: Mon Mar 10, 2014 8:18 am

Re: 12602 - Nice Licence Plates

Post by ashek.rahman » Mon Mar 24, 2014 7:44 am

@v1n1t...
Code AC. I am new in UVa OJ Board. For that reason did that kind of mistake.

Post Reply

Return to “Volume 126 (12600-12699)”