【CodeForces】[604A]Uncowed Forces

这里写图片描述

注意数据类型
防止精度丢失

#include<stdio.h>
double max(double a,double b) {
    return a>b?a:b;
}
int main() {
    int m[5];
    while(scanf("%d",&m[0])!=EOF) {
        int s[]= {500,1000,1500,2000,2500};
        for(int i=1; i<5; i++)
            scanf("%d",&m[i]);
        int w[5];
        for(int i=0; i<5; i++)
            scanf("%d",&w[i]);
        int h1,h2;
        scanf("%d %d",&h1,&h2);
        double sum=0;
        for(int i=0; i<5; i++) {
            sum+=max(0.3*s[i],(1-m[i]/250.0)*s[i]-50*w[i]);
        }
        printf("%.lf\n",sum+100*h1-50*h2);
    }
    return 0;
}

题目地址:【CodeForces】[604A]Uncowed Forces

posted @ 2016-07-21 15:25  BoilTask  阅读(12)  评论(0编辑  收藏  举报