Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

tips

Posted by ragnarok01 at 2013-10-06 22:22:55 on Problem 3296 and last updated at 2013-10-06 22:24:16
这题原始出处已经失效了,不过还好题目有备份:https://code.google.com/p/freeproblemset/downloads/list

但这里的标程在poj上交是WA的,主要原因如下:

(1) vb + vw < vr  要求直接输出单一个0;
(2) 不满足(1)但 vb==0 ,则输出k个0。

google了好久,把所有能交这题的oj都搜刮遍了,还hack出几个弱密码账号的ac源码,但来POJ交都是WA,不知道是什么原因。

修改过的标程如下:
#include<cstdio>

int main() {
    double vb, vw, vr, vc;
    int k, i;
    while(1) {
        scanf("%d %lf %lf %lf %lf", &k, &vb, &vw, &vr, &vc);
        if(k == 0) break;
        if(vb + vw < vr)
        {
            puts("0");
            continue;
        }
        double f = (vb+(k-1)*vr-(k-1)*vw)/k;
        if(f<0) f = 0;
        double leftover = vb-(k-1)*(vc-vr);
        if(f<leftover) f = leftover;
        if(f+vw>vc) f = vc-vw;
        if(f>vb) f= vb;
        double s = 0;
        if(k>1) {
            s = (vb-f)/(k-1);
            if(vr+s > vc) s=vc-vr;
        }
        printf("%d %.2f", k, f);
        for(i = 0; i < k-1; i++) {
            printf(" %.2f", s);
        }
        printf("\n");
    }
    return 0;
}

部分input:
2 15.0 25.0 1.0 50.0
3 15.0 8.0 3.0 10.0 
3 14.0 8.0 3.0 10.0 
3 30.0 25.0 1.0 50.0
3 30.0 5.0 1.0 50.0
3 0 5.0 1.0 50.0
3 0.2 0.5 1.0 50.0
3 200 0.5 1.0 50.0
0 

对应output:
2 0.00 15.00
3 1.67 6.67 6.67
3 1.33 6.33 6.33
3 0.00 15.00 15.00
3 7.33 11.33 11.33
3 0.00 0.00 0.00
0
3 49.50 49.00 49.00

另外这题三分甚至爆搜都能过。

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator