Skip to content

Instantly share code, notes, and snippets.

@markroxor
Last active September 8, 2015 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markroxor/90c223abdc010daedca5 to your computer and use it in GitHub Desktop.
Save markroxor/90c223abdc010daedca5 to your computer and use it in GitHub Desktop.
Correct - BANROB (LONG SEPT CF)
#include<bits/stdc++.h>
using namespace std;
main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
//freopen("output.txt","w",stdout);
#endif
ios::sync_with_stdio(0);
long long t;
cin >> t;
cout << fixed << setprecision(6);
while(t--)
{
long long m;
long double mon = 1000000000;
long double p;
cin >> m >> p;
long double fir;
if(m%2==1){
fir=mon*(1+pow(p,m));}
else
fir=mon*(1-pow(p,m));
fir/=(1+p);
cout << fir << ' ' << mon-fir << '\n';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment