/* * @(#) msu97_e.c - Problem 'E' ("The cubeloto") solution * of the ACM Programming Contest at the MSU in 1997. * (c) 1998 Ivan Maidanski http://ivmai.chat.ru * Freeware program source. All rights reserved. ** * Language: ANSI C * Tested with: Borland C++ v3.1 * Last modified: 1998-03-31 18:20:00 GMT+04:00 */ /* Input data file: e.dat */ #include /* FILE, fopen(), fscanf(), printf() */ #define MAXN 100 #define MDIG 35 char a[MAXN+1][MDIG],p[MDIG]; void init(char v[]) { int d; for (v[0]=d=1;d=10)) a[j][d]-=10; p[d]=t; } } int main(void) { int cnt,n,k,i,j; FILE *f=fopen("e.dat","rt"); fscanf(f,"%*[^0-9]%d",&cnt); while (cnt--) { fscanf(f,"%*[^0-9]%d%*[^0-9]%d",&n,&k); for (i=1;i<=n;i++) for (init(a[0]),init(a[i]),init(p),j=1;j=0;j--) if (a[k][j]) break; printf("+++++\n"); for (;j>=0;j--) printf("%d",a[k][j]); printf("0\n",a[k]); } printf("\n"); return 0; }