Saturday, June 6, 2015

LightOJ - 1104 - Birthday Paradox

  1. /****************#####    بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم  #####*******************
  2. __________________________________________________________________________
  3. ######################  Ya-Seen Arafat(ACWizard) #########################
  4. ######################        UAP-CSE-33B        #########################
  5. *************************************************************************/
  6. #include <bits/stdc++.h>
  7. #define sc(n) scanf("%d", &n)
  8. #define S 2003
  9. using namespace std;
  10. typedef long long LL;
  11. void Do(){
  12.     int t, n, tmp, ans, cs = 0;
  13.     double cn;
  14.     cin >> t;
  15.     while(t--){
  16.         cin >> n;
  17.         ans = 0; cn = 1.0;
  18.         for(int i = n; ; i--){
  19.             ans++;
  20.             cn *= (i/(double)n);
  21.             tmp = (1.0-cn)*1000000000;
  22.             if(tmp >= 500000000)break;
  23.         }
  24.         cout << "Case " << ++cs << ": " << --ans << endl;
  25.     }
  26. }
  27. int main(){
  28.     //ios_base::sync_with_stdio(0); cin.tie(0);
  29.     #ifndef ONLINE_JUDGE
  30.     ///freopen("inp","r",stdout);
  31.     ///freopen("contest.txt","w",stdout);
  32.     #endif
  33.     Do();
  34.     return 0;
  35. }

No comments:

Post a Comment