Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Why presentation error?

Posted by songuno1 at 2006-02-04 11:07:23 on Problem 1174
```#include <stdio.h>
#include <stdlib.h>
#define Lim 531442

int A, B, N, l;
int Tsqr[12];
int C[Lim][2];
int e[13];

void input (){
scanf ( "%d %d %d\n", &A, &B, &N );
}

void process (){
char inC;
int i, c, in;

Tsqr[0]=1;
for (i=1; i<B; i++) Tsqr[i]=Tsqr[i-1]*3;

for (i=0; i<Lim; i++) C[i][1]=i;

for (c=0;;c++){
if (c%80==0) scanf ( "\n" );
scanf ( "%c", &inC );
if (inC=='2') return;

in=inC-'0'+1;
for (i=A-1; i<B; i++){
e[i]*=3, e[i]+=in;
if (c>=i) C[e[i]][0]++, e[i]%=Tsqr[i];
}
}
}

void print ( int in ){
int i, val;

printf ( " " );

for (i=B-1; i>=0; i--){
if (in/Tsqr[i]>0) break;
}

while (i>=0){
val=in/Tsqr[i];
in%=Tsqr[i];
if (val==1) printf ( "0" );
if (val==2) printf ( "1" );
i--;
}
}

int sf ( const void *A, const void *B ){
int a=*(int *)A, b=*(int *)B;

if (a!=b) return b-a;

a=*((int *)A+1), b=*((int *)B+1);

return b-a;
}

void output (){
int i, u;

qsort ( C, Lim, sizeof ( C[0] ), sf );

for (i=0; N--; i++){
if (C[i][0]==0) break;
printf ( "%d", C[i][0] );
for (u=i;;u++){
if (C[i][0]==C[u][0] && (u-i) && (u-i)%6==0) printf ( "\n" );
if (C[i][0]==C[u][0]) print ( C[u][1] );
else break;
}
printf ( "\n" );
i=u-1;
}
}

int main (){
input ();
process ();
output ();
return 0;
}
```

Followed by: