Tuesday, 11 July 2017

UVa 00637 - Booklet Printing

This problem is an adhoc problem that asks to you to design a system to print folding booklets. The problem description and test cases can be found here.



Code


#include<iostream>

using namespace std;
int main(){
 
 while(1){
  int nop;
  cin>>nop;
  if(!nop) break;
  cout<<"Printing order for "<<nop<<" pages:\n";
  int sheet=nop/4;
  if(nop%4)sheet++;
  int side=sheet*4;
  int magicno=1+side;
  int pgno=1;
  for(int i=1;i<=sheet;i++){
   int a=magicno-pgno;
   int b=pgno;
   pgno++;
   int c=pgno;
   int d=magicno-pgno;
   pgno++;
   if(a>nop) a=0;
   if(b>nop) b=0;
   if(c>nop) c=0;
   if(d>nop) d=0;
   
   if(a) cout<<"Sheet "<<i<<", front: "<<a<<", "<<b<<"\n";
   else cout<<"Sheet "<<i<<", front: "<<"Blank"<<", "<<b<<"\n"; 
   if(c!=0 && d!=0) cout<<"Sheet "<<i<<", back : "<<c<<", "<<d<<"\n";
   else if(c) cout<<"Sheet "<<i<<", back : "<<c<<", "<<"Blank"<<"\n";
   else if (d) cout<<"Sheet "<<i<<", back : "<<"Blank"<<", "<<d<<"\n";
   
   
   }
  
  }
  return 0;
}

4 comments:

  1. Hold the paper in place and align the top arm over the spine. Hold the booklet in place with your hands or by placing a heavy object on top of each side.Align the stapler arm so the head of the stapler is oriented in the middle of the booklet, where you'd like the first staple to be.

    ReplyDelete
  2. If you are looking for cheap brochure printing services, BullPrint is here to help. We offer a range of brochures that are available in different sizes, including A4, A5, DL and 2xDL. We understand how brochure printing is important for you! That’s why we offer affordable brochure printing services without compromising quality.

    ReplyDelete
  3. Nice Post! Discover effortless and budget-friendly booklet printing at PrintStar Booklets!

    ReplyDelete