//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void TForm1::main() { char *stime[30],*etime[30]; __int64 tick1,tick2; tick1 = GetTickCount(); Form1->Cursor = crHourGlass; fid = fopen("log.txt","wt"); time(&t1); *stime = ctime(&t1); fprintf(fid,"*** pazul started : %s \n",*stime); Edit1->Text = *stime; Edit3->Text = IntToStr(time(&t2)-t1); Form1->Refresh(); exec(); tick2 = GetTickCount(); result = (int) (tick2 -tick1); time(&t2); *etime = ctime(&t2); fprintf(fid,"\n*** pazul ended time = %d ms : %s \n",result,*etime); Edit2->Text = *etime; Edit3->Text = IntToStr(t2-t1); Edit4->Text = IntToStr(result); fclose(fid); // reset cursor mark Form1->Cursor = crDefault; } //--------------------------------------------------------------------------- void TForm1::exec() { int N,a1,a2,b1,b2; int large = 1000000000; A[0] = 1; B[0] = 1; fprintf(fid," A[N] B[N] \n"); for (N=1; N<=45; N++) { A[N] = funcA(N); B[N] = funcB(N); //print A[n],B[n] fprintf(fid,"*** N =%3d ",N); if (A[N] b) { if (a > (b+c+d+1)) continue; if (a < (b+c+d+1)) ff = funcB(a,b,c,d); else if (sw == 0) continue; else { sw = 0; ff = fai2(a); } } // fprintf(fid,"*** a=%d,b=%d,c=%d,d=%d, ff=%Ld\n",a,b,c,d,ff); // fflush(fid); f += ff; } } } return f; } //--------------------------------------------------------------------------- __int64 TForm1::funcB(int a,int b,int c,int d) { if ((a == b) && (b == c) && (c == d)) return fai4(a); if ((a == b) && (b == c)) return (fai3(a)*fai(d)); if ((b == c) && (c == d)) return (fai(a)*fai3(b)); if ((a == b) && (c == d)) return (fai2(a)*fai2(c)); if (a == b) return (fai2(a)*fai(c)*fai(d)); if (b == c) return (fai(a)*fai2(b)*fai(d)); if (c == d) return (fai(a)*fai(b)*fai2(c)); return (fai(a)*fai(b)*fai(c)*fai(d)); } //--------------------------------------------------------------------------- __int64 TForm1::fai(int n) { return A[n]; } __int64 TForm1::fai2(int n) { __int64 f = A[n]; return f*(f+1)/2; } __int64 TForm1::fai3(int n) { __int64 f = A[n]; return (f+f*(f-1)+f*(f-1)*(f-2)/6); } __int64 TForm1::fai4(int n) { __int64 f = A[n]; return (f+f*(f-1)*3/2+f*(f-1)*(f-2)/2+f*(f-1)*(f-2)*(f-3)/24); } //--------------------------------------------------------------------------- void __fastcall TForm1::FormClick(TObject *Sender) { main(); } //---------------------------------------------------------------------------