From Codeforces round 363

Source: Internet
Author: User

This is the case: the same program, running on my own computer is the correct result, and submitted to the CF evaluation machine for the same input data, the results are actually different! No problems were found after repeated checks. The suspicion may be related to memset at the moment, because when I change the AC code to close to my own program, I have the same condition (my program is exactly the same as the standard, and the code is almost identical).

Comparison of my program with the standard path:

My program:

#include <stdio.h>#include<string.h>Doublep[ +],ans[ +],dp[1<< -+ -];intMain () {//freopen ("Input.txt", "R", stdin);    intn,k; scanf ("%d%d",&n,&K); memset (ans,0,sizeof(ans)); Memset (DP,0,sizeof(DP));  for(intI=0; i<n;i++) scanf ("%LF",&P[i]); dp[0]=1;  for(intI=1;i< (1&LT;&LT;N); i++)    {        Doublesp=0; intCnt=0;  for(intj=0; j<n;j++)            if((i& (1&LT;&LT;J)) = =0) {CNT++; SP+=P[j]; }        if(n-cnt>k)Continue;  for(intj=0; j<n;j++)            {                 if(p[j]<0.000000001)Continue; if(((1&LT;&LT;J) &i)! =0) {Dp[i]+=dp[i-(1&LT;&LT;J)]*p[j]/(sp+P[j]); ANS[J]+=dp[i-(1&LT;&LT;J)]*p[j]/(sp+P[j]); }             }    }     for(intI=0; i<n;i++) printf ("%.9LF", Ans[i]); //fclose (stdin);    return 0;}
View Code

Standard process:

#include <stdio.h>intN, K;Doublep[ A];Doubleans[ A];Doubledp[1<< -+ -];intMain () {intK; Doublesp; scanf ("%d%d", &n, &K);  for(inti =0; i < N; i++) {scanf ("%LF", &P[i]); } dp[0] =1;  for(inti =1; I < (1<< N); i++) {SP=0; K=0;  for(intj =0; J < N; J + + )        {            if( ( (1<< j) &i) = =0) {SP+=P[j]; K++; }        }        if(N-k > K)Continue;  for(intj =0; J < N; J + + )        {            if(P[j] <0.000000001)Continue; if( ( (1<< j) &i)! =0) {Dp[i]+ = Dp[i-(1<< j)] * P[j]/(sp +P[j]); ANS[J]+ = Dp[i-(1<< j)] * P[j]/(sp +P[j]); }        }    }     for(inti =0; i < N; i++) {printf ("%.10LF", Ans[i]); }    return 0;}
View Code

Submit Record:

  

 Error Result:

  

I swear, running on my own computer, whether it is my own program or the standard process, the output is the correct result, but a submission, the result is wrong.

From Codeforces round 363

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.