637 - Booklet Printing
Moderator: Board moderators
637 - Booklet Printing
Does anybody notice that even though problem 637 has more than 60% accepted, but only 10% of them is really correct. all 90% have Presentation Error. It means only 6% overall is accepted.
I don't know what's wrong with my program below. It produced exactly the same output as the sample output, but still got PE.
can anybody help ?
[c]void main ( void ){
while (1){
int i, n;
int a, b, c;
scanf ( "%d\n", &n );
if ( !n ) break;
printf ( "Printing order for %d pages:\n", n );
a = (n%4) ? n/4 + 1 : n/4;
b = a * 4;
c = 1;
for ( i = 1; i <= a; i++){
printf ( "Sheet %2d, front: ", i );
if ( b > n )
printf ( "Blank" );
else
printf ( "%d", b );
b--;
printf ( ", %d\n", c );
c++;
if ( (c > n) && (b > n) )
continue;
printf ( "Sheet %2d, back : ", i );
if ( c > n )
printf ( "Blank" );
else
printf ( "%d", c );
c++;
if ( b > n )
printf ( ", Blank\n" );
else
printf ( ", %d\n", b );
b--;
}
}
}[/c]
I don't know what's wrong with my program below. It produced exactly the same output as the sample output, but still got PE.
can anybody help ?
[c]void main ( void ){
while (1){
int i, n;
int a, b, c;
scanf ( "%d\n", &n );
if ( !n ) break;
printf ( "Printing order for %d pages:\n", n );
a = (n%4) ? n/4 + 1 : n/4;
b = a * 4;
c = 1;
for ( i = 1; i <= a; i++){
printf ( "Sheet %2d, front: ", i );
if ( b > n )
printf ( "Blank" );
else
printf ( "%d", b );
b--;
printf ( ", %d\n", c );
c++;
if ( (c > n) && (b > n) )
continue;
printf ( "Sheet %2d, back : ", i );
if ( c > n )
printf ( "Blank" );
else
printf ( "%d", c );
c++;
if ( b > n )
printf ( ", Blank\n" );
else
printf ( ", %d\n", b );
b--;
}
}
}[/c]
637:Booklet Printing : P.E.
Does anybody notice that even though problem 637 has more than 60% accepted, but only 10% of them is really correct. all 90% have Presentation Error. It means only 6% overall is accepted.
I don't know what's wrong with my program below. It produced exactly the same output as the sample output, but still got PE.
can anybody help ?
[c]void main ( void ){
while (1){
int i, n;
int a, b, c;
scanf ( "%d\n", &n );
if ( !n ) break;
printf ( "Printing order for %d pages:\n", n );
a = (n%4) ? n/4 + 1 : n/4;
b = a * 4;
c = 1;
for ( i = 1; i <= a; i++){
printf ( "Sheet %2d, front: ", i );
if ( b > n )
printf ( "Blank" );
else
printf ( "%d", b );
b--;
printf ( ", %d\n", c );
c++;
if ( (c > n) && (b > n) )
continue;
printf ( "Sheet %2d, back : ", i );
if ( c > n )
printf ( "Blank" );
else
printf ( "%d", c );
c++;
if ( b > n )
printf ( ", Blank\n" );
else
printf ( ", %d\n", b );
b--;
}
}
}[/c]
I don't know what's wrong with my program below. It produced exactly the same output as the sample output, but still got PE.
can anybody help ?
[c]void main ( void ){
while (1){
int i, n;
int a, b, c;
scanf ( "%d\n", &n );
if ( !n ) break;
printf ( "Printing order for %d pages:\n", n );
a = (n%4) ? n/4 + 1 : n/4;
b = a * 4;
c = 1;
for ( i = 1; i <= a; i++){
printf ( "Sheet %2d, front: ", i );
if ( b > n )
printf ( "Blank" );
else
printf ( "%d", b );
b--;
printf ( ", %d\n", c );
c++;
if ( (c > n) && (b > n) )
continue;
printf ( "Sheet %2d, back : ", i );
if ( c > n )
printf ( "Blank" );
else
printf ( "%d", c );
c++;
if ( b > n )
printf ( ", Blank\n" );
else
printf ( ", %d\n", b );
b--;
}
}
}[/c]
correction
Sorry.
My program is [c]printf ( "Sheet %d,...[/c] not [c]printf ( "Sheet %2d,...[/c]
the %2d was my experiment.
My program is [c]printf ( "Sheet %d,...[/c] not [c]printf ( "Sheet %2d,...[/c]
the %2d was my experiment.
637...why PE??
Would you plz chq where is the problem in my code that results Presentation Error??? number 637.
Here is the code..
//637...Booklet printing
#include<math.h> //for ceil()
#include<stdio.h>
int main()
{
int a[25][4];
int i,j,count,page_req;
int x;
while( (1==scanf("%d",&page_req))&&page_req)
{
printf("Printing order for %d pages:\n",page_req);
count=1;
x= (int)ceil(page_req/4.0);
for(i=0; i<x; i++)
{
if(count<=page_req) a[1]=count++;
else a[1]=0;
if(count<=page_req) a[2]=count++;
else a[2]=0;
}
for(i=x-1; i>=0; i--)
{
if(count<=page_req) a[3]=count++;
else a[3]=0;
if(count<=page_req) a[0]=count++;
else a[0]=0;
}
for(i=0; i<x; i++)
{
if(a[0]+a[1]!=0)
{
printf("Sheet %d, front:",i+1);
for(j=0; j<2; j++)
{
if(a[i][j]==0)printf(" Blank");
else printf(" %d",a[i][j]);
if(j==0)printf(",");
}
printf("\n");
}
if(a[i][2]+a[i][3]!=0)
{
printf("Sheet %d, back :",i+1);
for(j=2; j<4; j++)
{
if(a[i][j]==0)printf(" Blank");
else printf(" %d",a[i][j]);
if(j==2)printf(",");
}
printf("\n");
}
}
}
return 0;
}
Thank you in Advance
Ashis
Here is the code..
//637...Booklet printing
#include<math.h> //for ceil()
#include<stdio.h>
int main()
{
int a[25][4];
int i,j,count,page_req;
int x;
while( (1==scanf("%d",&page_req))&&page_req)
{
printf("Printing order for %d pages:\n",page_req);
count=1;
x= (int)ceil(page_req/4.0);
for(i=0; i<x; i++)
{
if(count<=page_req) a[1]=count++;
else a[1]=0;
if(count<=page_req) a[2]=count++;
else a[2]=0;
}
for(i=x-1; i>=0; i--)
{
if(count<=page_req) a[3]=count++;
else a[3]=0;
if(count<=page_req) a[0]=count++;
else a[0]=0;
}
for(i=0; i<x; i++)
{
if(a[0]+a[1]!=0)
{
printf("Sheet %d, front:",i+1);
for(j=0; j<2; j++)
{
if(a[i][j]==0)printf(" Blank");
else printf(" %d",a[i][j]);
if(j==0)printf(",");
}
printf("\n");
}
if(a[i][2]+a[i][3]!=0)
{
printf("Sheet %d, back :",i+1);
for(j=2; j<4; j++)
{
if(a[i][j]==0)printf(" Blank");
else printf(" %d",a[i][j]);
if(j==2)printf(",");
}
printf("\n");
}
}
}
return 0;
}
Thank you in Advance
Ashis
sirf_A S H I S
637 - Booklet Printing - Need outputs!
Hi guys, ive got no trouble on coding the problem, and my answers seems all to be correct, but i'm getting WA's. I'm gonna post my program output for the following input just to show that i've coded this problem, in fact what I'd like to receive in my email (jemersonfd@gmail.com) is all possible outputs (1 to 100) so that I could compare them with mine to find the bug, or, if any Java programmer decide to help me I can show my code here. Thanx!
Input:
Output:
Input:
Code: Select all
1
2
3
4
5
6
7
8
9
10
11
12
99
100
0
Code: Select all
Printing order for 1 pages:
Sheet 1, front: Blank, 1
Printing order for 2 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, Blank
Printing order for 3 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, 3
Printing order for 4 pages:
Sheet 1, front: 4, 1
Sheet 1, back : 2, 3
Printing order for 5 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, 5
Sheet 2, front: 4, 3
Printing order for 6 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, Blank
Sheet 2, front: 6, 3
Sheet 2, back : 4, 5
Printing order for 7 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, 7
Sheet 2, front: 6, 3
Sheet 2, back : 4, 5
Printing order for 8 pages:
Sheet 1, front: 8, 1
Sheet 1, back : 2, 7
Sheet 2, front: 6, 3
Sheet 2, back : 4, 5
Printing order for 9 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, 9
Sheet 2, front: 8, 3
Sheet 2, back : 4, 7
Sheet 3, front: 6, 5
Printing order for 10 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, Blank
Sheet 2, front: 10, 3
Sheet 2, back : 4, 9
Sheet 3, front: 8, 5
Sheet 3, back : 6, 7
Printing order for 11 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, 11
Sheet 2, front: 10, 3
Sheet 2, back : 4, 9
Sheet 3, front: 8, 5
Sheet 3, back : 6, 7
Printing order for 12 pages:
Sheet 1, front: 12, 1
Sheet 1, back : 2, 11
Sheet 2, front: 10, 3
Sheet 2, back : 4, 9
Sheet 3, front: 8, 5
Sheet 3, back : 6, 7
Printing order for 99 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, 99
Sheet 2, front: 98, 3
Sheet 2, back : 4, 97
Sheet 3, front: 96, 5
Sheet 3, back : 6, 95
Sheet 4, front: 94, 7
Sheet 4, back : 8, 93
Sheet 5, front: 92, 9
Sheet 5, back : 10, 91
Sheet 6, front: 90, 11
Sheet 6, back : 12, 89
Sheet 7, front: 88, 13
Sheet 7, back : 14, 87
Sheet 8, front: 86, 15
Sheet 8, back : 16, 85
Sheet 9, front: 84, 17
Sheet 9, back : 18, 83
Sheet 10, front: 82, 19
Sheet 10, back : 20, 81
Sheet 11, front: 80, 21
Sheet 11, back : 22, 79
Sheet 12, front: 78, 23
Sheet 12, back : 24, 77
Sheet 13, front: 76, 25
Sheet 13, back : 26, 75
Sheet 14, front: 74, 27
Sheet 14, back : 28, 73
Sheet 15, front: 72, 29
Sheet 15, back : 30, 71
Sheet 16, front: 70, 31
Sheet 16, back : 32, 69
Sheet 17, front: 68, 33
Sheet 17, back : 34, 67
Sheet 18, front: 66, 35
Sheet 18, back : 36, 65
Sheet 19, front: 64, 37
Sheet 19, back : 38, 63
Sheet 20, front: 62, 39
Sheet 20, back : 40, 61
Sheet 21, front: 60, 41
Sheet 21, back : 42, 59
Sheet 22, front: 58, 43
Sheet 22, back : 44, 57
Sheet 23, front: 56, 45
Sheet 23, back : 46, 55
Sheet 24, front: 54, 47
Sheet 24, back : 48, 53
Sheet 25, front: 52, 49
Sheet 25, back : 50, 51
Printing order for 100 pages:
Sheet 1, front: 100, 1
Sheet 1, back : 2, 99
Sheet 2, front: 98, 3
Sheet 2, back : 4, 97
Sheet 3, front: 96, 5
Sheet 3, back : 6, 95
Sheet 4, front: 94, 7
Sheet 4, back : 8, 93
Sheet 5, front: 92, 9
Sheet 5, back : 10, 91
Sheet 6, front: 90, 11
Sheet 6, back : 12, 89
Sheet 7, front: 88, 13
Sheet 7, back : 14, 87
Sheet 8, front: 86, 15
Sheet 8, back : 16, 85
Sheet 9, front: 84, 17
Sheet 9, back : 18, 83
Sheet 10, front: 82, 19
Sheet 10, back : 20, 81
Sheet 11, front: 80, 21
Sheet 11, back : 22, 79
Sheet 12, front: 78, 23
Sheet 12, back : 24, 77
Sheet 13, front: 76, 25
Sheet 13, back : 26, 75
Sheet 14, front: 74, 27
Sheet 14, back : 28, 73
Sheet 15, front: 72, 29
Sheet 15, back : 30, 71
Sheet 16, front: 70, 31
Sheet 16, back : 32, 69
Sheet 17, front: 68, 33
Sheet 17, back : 34, 67
Sheet 18, front: 66, 35
Sheet 18, back : 36, 65
Sheet 19, front: 64, 37
Sheet 19, back : 38, 63
Sheet 20, front: 62, 39
Sheet 20, back : 40, 61
Sheet 21, front: 60, 41
Sheet 21, back : 42, 59
Sheet 22, front: 58, 43
Sheet 22, back : 44, 57
Sheet 23, front: 56, 45
Sheet 23, back : 46, 55
Sheet 24, front: 54, 47
Sheet 24, back : 48, 53
Sheet 25, front: 52, 49
Sheet 25, back : 50, 51
UFCG Brazil - Computer Science graduate student
http://acm.uva.es/problemset/usersnew.php?user=54806 ... and going up!
http://acm.uva.es/problemset/usersnew.php?user=54806 ... and going up!
I think if you solve this case correctly, you'll likely solve all cases correctly:
input:
output:
input:
Code: Select all
5
0
Code: Select all
Printing order for 5 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, Blank
Sheet 2, front: Blank, 3
Sheet 2, back : 4, 5
Ow man.. , as you can see I hadn't check my output very well
Thanx for showing my mistake.
![:oops:](./images/smilies/icon_redface.gif)
Thanx for showing my mistake.
UFCG Brazil - Computer Science graduate student
http://acm.uva.es/problemset/usersnew.php?user=54806 ... and going up!
http://acm.uva.es/problemset/usersnew.php?user=54806 ... and going up!
planadecu@default ~/concurs/acm/637 $ diff in out
1d0
<
15,16c14,16
< Sheet 1, back : 2, 5
< Sheet 2, front: 4, 3
---
> Sheet 1, back : 2, Blank
> Sheet 2, front: Blank, 3
> Sheet 2, back : 4, 5
34,37c34,38
< Sheet 1, back : 2, 9
< Sheet 2, front: 8, 3
< Sheet 2, back : 4, 7
< Sheet 3, front: 6, 5
---
> Sheet 1, back : 2, Blank
> Sheet 2, front: Blank, 3
> Sheet 2, back : 4, 9
> Sheet 3, front: 8, 5
> Sheet 3, back : 6, 7
160c161
< Sheet 25, back : 50, 51
\ No newline at end of file
---
> Sheet 25, back : 50, 51
1d0
<
15,16c14,16
< Sheet 1, back : 2, 5
< Sheet 2, front: 4, 3
---
> Sheet 1, back : 2, Blank
> Sheet 2, front: Blank, 3
> Sheet 2, back : 4, 5
34,37c34,38
< Sheet 1, back : 2, 9
< Sheet 2, front: 8, 3
< Sheet 2, back : 4, 7
< Sheet 3, front: 6, 5
---
> Sheet 1, back : 2, Blank
> Sheet 2, front: Blank, 3
> Sheet 2, back : 4, 9
> Sheet 3, front: 8, 5
> Sheet 3, back : 6, 7
160c161
< Sheet 25, back : 50, 51
\ No newline at end of file
---
> Sheet 25, back : 50, 51
Re: 637
My advice to you -> always copy/paste output format from sample or problem description.
Your output
Sample output
Don't forget to remove your code after getting accepted. ![8)](./images/smilies/icon_cool.gif)
![:)](./images/smilies/icon_smile.gif)
Your output
Code: Select all
Sheet 1, back: 2, Blank
Code: Select all
Sheet 1, back : 2, Blank
![8)](./images/smilies/icon_cool.gif)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman