zoukankan      html  css  js  c++  java
  • USACO 1.3 Ski Course Design

    今晚,看了一整晚的电影,下载了一整晚的$GTA4$(13G啊 卧槽。。。),额最近迅雷好像很不给力,下载速度很慢,外加今天考了六级,听力真是跪死-。-,

                                      clip_image001

    睡觉前做了一道$usaco$,最近很少做题啊QAQ

    ===========================华丽的主题分割线===========================

    暴力直接枚举,让$i$从$1$~$83$循环,每次假设最小值为$i$,然后在所有的$hill$的高度那里判断就OK

    /*
    ID:jusonal1
    PROG:skidesign
    LANG:C++
    */
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <vector>
    #include <algorithm>
    using namespace std;
    const int maxn = 1111;
    int n;
    int a[maxn];
    int main()
    {
        freopen("skidesign.in","r",stdin);
        freopen("skidesign.out","w",stdout);
        while(~scanf("%d",&n)) {
            int ans = 0x3f3f3f3f,tmp;
            for(int i = 1;i <= n;++i) scanf("%d",&a[i]);
            for(int i = 1;i <= 100 -17;++i) {
                   tmp = 0;
                for(int j = 1;j <= n;++j) {
                    if(a[j] < i) tmp += (a[j]-i)*(a[j]-i);
                    if(a[j] > i+17) tmp += (a[j]-i-17)*(a[j]-i-17);
                }
                ans = min(tmp,ans);
            }
            printf("%d
    ",ans);
        }
        return 0;
    }
  • 相关阅读:
    另一个博客
    友情链接&部分题目的密码
    知识点汇总
    一些模板的调试样例
    摘抄
    通过代理连接Microsoft Store和更新Windows系统
    模电复习
    Codeforces Round #583 F Employment
    杂感(三)
    杂感(二)
  • 原文地址:https://www.cnblogs.com/jusonalien/p/4176136.html
Copyright © 2011-2022 走看看