Advertisement
Shiam7777777

Untitled

Mar 15th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  4. #define ll long long
  5. #define ld double
  6. #define llu long long unsigned
  7.  
  8. int main()
  9. {
  10.     fast;
  11.     int t;
  12.     cin>>t;
  13.     for( int c = 1 ; c <= t ; c++ )
  14.     {
  15.         cout<<"Case "<<c<<": ";
  16.         int n , k;
  17.         cin>>n>>k;
  18.         if( n < k )
  19.         {
  20.             cout<<0<<endl;
  21.             continue;
  22.         }
  23.         llu ans = 1;
  24.         vector < int > div;
  25.         for( int i = 1 ; i <= k ; i++ )
  26.         {
  27.             div.push_back( i );
  28.         }
  29.         for( int i = 1 ; i <= k ; i++ )
  30.         {
  31.             ans *= pow( n - i + 1 , 2 );
  32.             for( int x = 0 ; x < div.size() ; x++ )
  33.             {
  34.                 if( ans % div[x] == 0 )
  35.                 {
  36.                     ans /= div[x];
  37.                     div[x] = 1;
  38.                 }
  39.             }
  40. //            cout<<ans<<endl;
  41.         }
  42. //        for( int i = 1 ; i <= k ; i++ )
  43. //            ans /= i;
  44.         cout<<ans<<endl;
  45.     }
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement