#include <iostream>
#include <ctime>
using namespace std;
int main( ) {
unsigned int start_time1,start_time2,start_time3,search_time1,search_time2,search_time3;
int i,y,u,m,n,h,j,x;
long long c3= 0 ;
cin >> m;
cin >> n;
double k= m,c2= 1 ,c1;
long long D[ m+ 3 ] [ n+ 1 ] ;
double b= m- n, q= n, w= m, z= b;
if ( m> n && n>= 1 )
{
start_time1 = clock ( ) ;
for ( i= 1 ; i< n; i++ ) { q= q* i; }
for ( y= 1 ; y< m; y++ ) { w= w* y; }
for ( u= 1 ; u< b; u++ ) { z= z* u; }
c1= w/ ( q* z) ;
cout << "По первой формуле равно:" << c1<< " " << endl;
search_time1 = clock ( ) - start_time1;
start_time2 = clock ( ) ;
for ( i= n; i>= 1 ; i-- )
{
c2* = ( k- i+ 1 ) / i;
}
cout << "По второй формуле равно:" << c2<< " " << endl;
search_time2 = clock ( ) - start_time2;
start_time3 = clock ( ) ;
for ( y= 1 ; y<= m; y++ ) // Для каждой строки.
{
D[ y] [ 1 ] = y;
D[ y] [ y] = 1 ;
for ( x= 2 ; x<= n && x< y; x++ )
{
D[ y] [ x] = D[ y- 1 ] [ x- 1 ] + D[ y- 1 ] [ x] ;
}
}
c3= D[ m] [ n] ;
cout << "По третьей формyле равно:" << c3<< " " << endl;
search_time3 = clock ( ) - start_time3;
}
else if ( m< n) {
cout << "invalid" ;
}
cout << "Первая формула сработала за:(в милисек)" << ( ( double ) search_time1/ CLOCKS_PER_SEC ) * 1000 << endl;
cout << "Вторая формула сработала за:(в милисек)" << ( double ) search_time2/ CLOCKS_PER_SEC * 1000 << endl;
cout << "Третья формула сработала за:(в милисек)" << ( double ) search_time3/ CLOCKS_PER_SEC * 1000 << endl;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3RpbWU+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCXVuc2lnbmVkIGludCBzdGFydF90aW1lMSxzdGFydF90aW1lMixzdGFydF90aW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