/* * @(#) msu99_e.c - Problem 'E' ("Plague") solution * of the ACM Programming Contest at the MSU in 1999. * (c) 1999 Ivan Maidanski http://ivmai.chat.ru * Freeware program source. All rights reserved. ** * Language: ANSI C * Tested with: Borland C++ v3.1 * Last modified: 1999-03-28 20:25:00 GMT+04:00 */ /* Input data file: e.dat */ #include /* FILE, EOF, fopen(), fscanf(), printf() */ #define MAXP 1000 int a[MAXP]; int main() { int k,curk,p; long n,q1,q2,t; FILE *f=fopen("e.dat","rt"); if (fscanf(f,"%*[^0-9]%d",&k)==EOF) return 1; for (curk=1;curk<=k;curk++) { if (fscanf(f,"%*[^0-9]%ld",&n)==EOF) return 1; for (p=0;n;p++) { for (a[p]=0,q1=q2=1;q2<=n;a[p]++,t=q2,q2+=q1,q1=t); n-=q1; } printf("E %d %d",curk,p); while (p--) printf(" %d",a[p]-1); printf("\n"); } return 0; }