Skip to content

Instantly share code, notes, and snippets.

@markroxor
Created September 8, 2015 13:26
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/2ed20fcff2eb943ac523 to your computer and use it in GitHub Desktop.
Save markroxor/2ed20fcff2eb943ac523 to your computer and use it in GitHub Desktop.
Wrong CPP solution
#include<bits/stdc++.h>
using namespace std;
main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
//freopen("output.txt","w",stdout);
#endif
long long t;
scanf("%lld",&t);
while(t--)
{
long long m;
long double mon = 1000000000;
long double p;
scanf("%lld%Lf",&m,&p);
if(!p)
{
if(m%2==1)
printf("1000000000.000000 0.000000\n");
else
printf("0.000000 1000000000.000000\n");
continue;
}
long double fir;
if(m%2==1)
fir=mon*(1+pow(p,m));
else
fir=mon*(1-pow(p,m));
fir/=(1+p);
printf("%Lf %Lf\n",fir,mon-fir);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment