Page 6 of 12

Posted: Thu Aug 28, 2003 8:04 am
by Dominik Michniewski
ungetc() is valid function for judges ... If I correct remember , I got Acc a few problems used this function :)

Best regards

Posted: Thu Aug 28, 2003 9:15 pm
by SilVer DirectXer
XX-0000000000-XX is correct???


how about

oh, hard to identify if it is valid or not..

Posted: Thu Aug 28, 2003 9:42 pm
by UFP2161
I have these differences in output (y is my file, z is output above):

Code: Select all

diff y z
< XX-0000000000-XX is incorrect. <-- y
< XX000000XXX0000XXXXX is incorrect.
> XX-0000000000-XX is correct. <-- z
> XX000000XXX0000XXXXX is correct.
< 0-89237 -010 -6 is incorrect. <-- y
> 0-89237 -010 -6 is correct. <-- z
I believe mine is the more correct output, since an ISBN cannot start with 'X' .. and there cannot be spaces inside the ISBN number.


Code: Select all

AA-0000000000-AA is incorrect.

333 - Always WA

Posted: Thu Nov 27, 2003 10:46 am
by FaisalBD
I get WA just now. :cry: . But i have a confusion in output format.
If a input has starting and trailing space what is the output.
Plz sent me correct output of following input.
0-1-2-3-4-5-6-7-8-9-X \n
0- 1- 2- 3-4-5 -6-7-8-9-X\n
0-13-162959-X 0-13-162959-X\n
0 -13-162959-X\n
\n => enter or new line

333 , i have some question to ask ..........................

Posted: Tue Dec 02, 2003 6:20 am
by Riyad
pliz help me in getting ans to the following questions :--

1) what if there is illegal character inside a ISBN . will it count as a valid ISBN ?????
example :- 0abc-13dfasdfa-162959-X
0 -13-162959-X====> contains space inside the ISBN

2)what if there is an X in front of the ISBN .that means containing X in arbitary positions
rather than position 10 where it is counted as a valid character. will it count as a valid
ISBN ??????
XXXX-0-89237-010-6 ====> is it correct ??????

3)what will happen if an ISBN contains more than 10 digits . some thing like this

0-89237-010-6-----0-89237-010-6.though the first part of this is a valid ISBN(0-89237-010-6)
so will the complete line will be a valid ISBN(0-89237-010-6-----0-89237-010-6).

My algorithm for this prob is quiet simple :

1) read the input .
2)if it is a blank line output :incorrect
3)if it is not a blank line , than remove the leading and trailing blanks .
4)parse the digit from the string in to an integer array and when it contains X at the 10
position it is okay .
5)than by array operation calculate S1(partial sum)
6)than by array operation calculate S2(partial sum)
7)check wheither (s2[last-1] % 11 )==0
8)if yes output : correct
9)else output : incorrect

## i assumed no valid ISBN can contain illegal characters(space , tab , _ ,....) inside the

## i also assumed X is only valid when it is on the 10 th position .in other case it is
counted as invalid
## when ever it contains more than 10 digit , i assumed it to be an invalid ISBN .

AM i right with my assumptions ?? pliz help me . i am getting Wa all the time .

i did not want to paste my clumpsy code here . if any one want to see my code . i can mail
him my code .


Posted: Tue Dec 02, 2003 9:56 am
by deddy one
in my accepted solution

1. valid isbn may contain white space
2. it should be 10 digit ( X is counted as digit if there is any )
3. if there is any X it must be occurs once and in the tenth position

some one help me to get 333 AC

Posted: Tue Dec 02, 2003 3:24 pm
by Riyad
i have tried all possible way to solve 333 . but after several submission i am continuously getting WA . i know the algorithm for this prob is not that complicated but for the difficult input set . so can any one help me in this , what i am missing and if have made any stupid mistake .

[cpp] [/cpp]

plizzzzzzzzzzz help me in this

hey for every body who is trying 333

Posted: Wed Dec 03, 2003 5:59 pm
by Riyad
the algorithm for the prob 333 as i mentioned before is not that complicated . but it has got a strict input set . i ll like to with draw this line ------->>>>>{{{{more over people tend to make it more complicated by saying their AC program has given an ISBN containing spaces in between as Correct ISBN}}}} . But as a matter of fact after getting AC i realized some thing about 333 which i am telling in this post .

some says inputs like
0-89237<space><space><space><space>-010-6 are right , there AC programs give the above input to be correct but my AC program give this input to be incorrect . as both of us r AC that means there is no such inputs containing spaces in between an isbn in the judge input data(But i am not that sure :wink: ) . But it definitely contains Empty lines as inputs . more over X is only valid when it is in the 10 th position of the isbn .

so the theme of my writing is after removing trailing and leading spaces and also inner Hypens the ISBN string should have the length of 10 . so no illegal character is allowed ............
i ll also love to with draw this line ------------>>>>>>>>>so dont get distracted by different type of posts .Best Regards...

333 Clarification

Posted: Sat Jan 10, 2004 9:29 pm
by ravingavin
Hello All,

I've read in some of the posts that spaces between ISBN numbers ARE NOT tested but spaces before and after the ISBN are tested. I've read in some other posts that spaces between the ISBN number ARE tested and that spaces before and after then ISBN are also tested.

Could anyone clarify this for me????

My program does not check for spaces between the ISBN only after.

I get WA

#include <iostream>
#include <cctype>
#include <cstring>

using namespace std;

int main(){

char *isbn;
isbn = new char[81];
int sum=0;
int partialsum=0;
int number_of_digits=0;
int num_of_errors=0;

while(cin >> isbn){

for(int i=0; i<strlen(isbn); i++){

sum += (isbn - 48);
partialsum += sum;

cout << "Sum: " << sum << endl;
cout << "Partial Sum: " << partialsum << endl;
cout << "Number of Digits: " << number_of_digits << endl;
else if(isbn == 'X' && number_of_digits == 9){
sum += 10;
partialsum += sum;

cout << "Sum: " << sum << endl;
cout << "Partial Sum: " << partialsum << endl;
cout << "Number of Digits: " << number_of_digits << endl;

if(!isdigit(isbn) && isbn != 'X' && isbn != '-')


if(number_of_digits == 10 && partialsum%11 == 0 && num_of_errors == 0)
cout << isbn << " is correct." << endl;

cout << isbn << " is incorrect." << endl;

sum = 0;

delete [] isbn;
isbn = new char[81];

return 0;


Appreciate the help!!!

Thanks ,


Thank you Little Joey

Posted: Wed Jun 30, 2004 1:19 pm
by helmet
Just a small thank you to lil Joey for the immense help his sample input/output gave.

(After majjar fight I got AC)

333 ISBN numbers WA

Posted: Sat Nov 06, 2004 4:45 am
by Rony
Can any one help me ? Why I am getting wrong answer ? Can any one give me some inputs/outputs or check my code where is the problem.

Code C:

char str[100];
int i,counter,len,s1,s2;
void str_rev(char *s){

int i,j;
char temp;
len = strlen(str);

void check(char *s){

int i;
if(str!=32) break;

int main()





else if(str=='X'){s1+=10;s2+=s1;counter++;}


if((s2%11) ||(counter!=10)) printf("%s is incorrect.\n",str);
else printf("%s is correct.\n",str);



return 0;


Posted: Mon Nov 08, 2004 11:34 am
by dt96hasv
Testing your code with the following two examples:

Code: Select all

The correct answer should be

Code: Select all

0823025713 is correct.
082<space>3025713 is incorrect.
While your program answers:

Code: Select all

<tab><space>0823025713 is correct.
082<space>3025713 is correct.
I.e. you have to treat tabs as whitespace also, and you also seems to have an issue with whitespaces embedded inside the ISBN-numbers.

Another thing, your code would be easier to understand if you use '\n' instead of 32 and so on...

Hope this helps you some!


Posted: Thu Feb 10, 2005 4:02 pm
by Cahoun
Very good method is using gets method to read whole line input not scanf(%s\n",st).
Then you remove preceded and additional spaces.

333 - Recognizing Good ISBNs

Posted: Fri May 06, 2005 7:46 pm
by Jemerson
hi everyone,

I've already tryied all inputs and got the correct outputs suggested in the other 333's topic, but still got WA, here they are:

Code: Select all

This   just    for test. 
0-89237-010-6 TEST

082 3025713 
0823025		713 
013152447X bla 
0-1-3-1-5-2-4-4-7-X- - 
01 0111 
The outputs suggested and also generated by my code were:

Code: Select all

0-8104-5687-7 is correct.
0-8104-5687-7432 is incorrect.
This   just    for test. is incorrect.
0-1000-99999 is incorrect.
0-123-4567-89 is correct.
0-123-4567-890 is incorrect.
1-111-111-111 is correct.
0-89237-010-6 is correct.
0-89237-010-6 TEST is incorrect.
XX-0000000000-XX is correct.
XX000000XXX0000XXXXX is correct.
1234567890 is incorrect.
0823025713 is correct.
013152447X is correct.
013152447x is incorrect.
 is incorrect.
082302571 is incorrect.
08230257130 is incorrect.
2803025713 is incorrect.
07632200X1 is incorrect.
0823025713 is correct.
0823025713 is correct.
0823025713 is correct.
0823025713 is correct.
0823025713 is correct.
082 3025713 is incorrect.
0823025		713 is incorrect.
--08-2----302--5713------ is correct.
082302_5713 is incorrect.
013152447X bla is incorrect.
013-A-152447X is incorrect.
0-1-3-1-5-2-4-4-7-X- - is incorrect.
01315 is incorrect.
2447X is incorrect.
01-10 is incorrect.
01-434435 is incorrect.
01 0111 is incorrect.
May anyone who has already got this problem solved make sure this output is correct? And also suggest other extreme cases? 'Cause i dont know what else to do.

Posted: Fri May 06, 2005 8:42 pm
by Digit
There are some differences to my output:

Your program says:
XX-0000000000-XX is correct.
XX000000XXX0000XXXXX is correct.

My (accepted) program says:
XX-0000000000-XX is incorrect.
XX000000XXX0000XXXXX is incorrect.