|
|
вернуться в форумo(100000000) #include<stdio.h> void main() {
int a[10]; int i,j,n,i1,i2,i3,i4,i5,i6,i7,i8; a[1]=10; a[2]=10; a[4]=0; a[6]=0; a[8]=0; for(i1=0;i1<=9;i1++) for(i2=0;i2<=9;i2++) for(i3=0;i3<=9;i3++) for(i4=0;i4<=9;i4++) if ((i1+i2)==(i3+i4)) a[4]++; for(i1=0;i1<=9;i1++) for(i2=0;i2<=9;i2++) for(i3=0;i3<=9;i3++) for(i4=0;i4<=9;i4++) for(i5=0;i5<=9;i5++) for(i6=0;i6<=9;i6++) if((i1+i2+i3)==(i4+i5+i6)) a[6]++; for(i1=0;i1<=9;i1++) for(i2=0;i2<=9;i2++) for(i3=0;i3<=9;i3++) for(i4=0;i4<=9;i4++) for(i5=0;i5<=9;i5++) for(i6=0;i6<=9;i6++) for(i7=0;i7<=9;i7++) for(i8=0;i8<=9;i8++) if((i1+i2+i3+i4)==(i5+i6+i7+i8)) a[8]++;
scanf("%d",&n); printf("%d",a[n]);
} o(100000000) 0.218sec Re: o(100000000) can u tell me how to solve this problem. Re: o(100000000) Послано phizaz 6 апр 2011 12:47 Thanks. you opened my eyes! Now, I write it in recursive terms of you! Edited by author 06.04.2011 12:58 Re: o(100000000) Послано phizaz 6 апр 2011 12:52 Explaination of that solution is... simulating number for each digits ... it's seems to "for(i=1;i<=99999999;i++)" but it's easier(faster) to check for SUM of first half and the second half. Edited by author 06.04.2011 12:53 Alisher_uz thank you very much |
|
|