Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main(){
- FILE *fin = fopen("testing/test_cases.txt","r");
- FILE *fout = fopen("testing/Coutput.txt","w");
- int test_cases;
- fscanf (fin, "%d\n", &test_cases );
- float p,gain;
- while(test_cases-- > 0){
- fscanf (fin, "%f\n", &p );
- if(p >= .5){
- gain = 10000 * (1-p) * (2*p-1);
- }
- else{
- gain = p*(1-2*p)*10000;
- }
- float val = 10000+gain;
- fprintf(fout, "%.6f\n",val);
- }
- fclose(fin);
- fclose(fout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement