Created
September 8, 2015 13:26
-
-
Save markroxor/2ed20fcff2eb943ac523 to your computer and use it in GitHub Desktop.
Wrong CPP solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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