POJ水题大联欢

poj2017

纯水题。。。。我只是vjudge登不上了才来做的安静

#include <iostream>
#include <cstdio>

using namespace std;

const int MaxN = 13;
int s[MaxN], t[MaxN];
int ans, n;

int main()
{
    while(~scanf("%d", &n) && n!= -1){
        s[0] = t[0] = ans = 0;
        for(int i=1; i<=n; ++i){
            scanf("%d%d", &s[i], &t[i]);
            ans += s[i] * (t[i] - t[i - 1]);
        }
        printf("%d miles\n", ans);
    }
    return 0;
}

poj 2000

#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int n;
    while(scanf("%d", &n) && n){
        int d = 1, ans = 0;
        int i = 1;
        for(i=1; i<=n; i+=d){
            ans += d*d;
            d += 1;
        }
        i -= d;
        ans += d * (n - i);
        printf("%d %d\n", n, ans);
    }
    return 0;
}

poj 1046

#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

const int MaxN = 17;
struct rgb{
    int r, g, b;
};
rgb a[MaxN];
int cacd(const rgb& a, const rgb& b);
int main()
{
    for(int i=0; i<16; ++i){
        scanf("%d%d%d", &a[i].r, &a[i].g, &a[i].b);
    }
    rgb temp;
    while(scanf("%d%d%d", &temp.r, &temp.g, &temp.b) && temp.r > -1){
        int ans = 0, d = cacd(temp, a[0]);
        for(int i=0; i<16; ++i){
            int td = cacd(temp, a[i]);
            if(td < d){
                d = td;
                ans = i;
            }
        }
        printf("(%d,%d,%d) maps to (%d,%d,%d)\n", temp.r, temp.g, temp.b, a[ans].r, a[ans].g, a[ans].b);
    }
    return 0;
}

int cacd(const rgb& a, const rgb& b)
{
    return ((b.r - a.r) * (b.r - a.r) + (b.g - a.g) * (b.g - a.g) + (b.b - a.b) * (b.b - a.b));
}

poj 1003

#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

const double eps = 1e-8;

int main()
{
    double l;
    while(scanf("%lf", &l) && fabs(l) > eps){
        double rl = 0.5;
        int  i = 2;
        while(rl < l){
            ++i;
            rl += 1.0 / i;
        }
        printf("%d card(s)\n", i - 1);
    }
    return 0;
}
poj 1004 1005 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值