比赛 20111012 评测结果 AEEEEAWWAW
题目名称 抗击SARS 最终得分 30
用户昵称 苏轼 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2011-10-12 20:07:49
显示代码纯文本
#include <cstdio>

using namespace std;

long double bac[3048580];

#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)>(Y)?(Y):(X))

int main ()
{
    freopen("sars.in", "r", stdin);
    freopen("sars.out", "w", stdout);

    int x, r, l, v;
    scanf("%d%d%d%d", &x, &r, &l, &v);
    
    long double ll = l*2, rr = r + 0.00001, xx = 0;
    int head = 0, tail=1, ans=0;
    bac[0] = x;

    while (1)
    {
        for (int i=head; i<tail; i++)
            if (MAX(bac[i] - rr, xx) <= 
                    MIN(bac[i] + rr, xx+v))
            {
                ans++;
                break;
            }

        xx += v;
        if ((ll = ll/2) <= 1)
            break;
        int ohead = head;
        head = tail;
        for (int i=ohead; i<head; i++)
        {
            bac[tail++] = bac[i] - ll;
            bac[tail++] = bac[i] + ll;
        }
    }

    printf("%d\n", ans);

    return 0;
}