zoukankan      html  css  js  c++  java
  • AtCoder Beginner Contest 113 B

    B - Palace


    Time limit : 2sec / Memory limit : 1024MB

    Score: 200 points

    Problem Statement

    A country decides to build a palace.

    In this country, the average temperature of a point at an elevation of x meters is Tx×0.006 degrees Celsius.

    There are N places proposed for the place. The elevation of Place i is Hi meters.

    Among them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.

    Print the index of the place where the palace should be built.

    It is guaranteed that the solution is unique.

    Constraints

    • 1≤N≤1000
    • 0≤T≤50
    • −60≤AT
    • 0≤Hi≤105
    • All values in input are integers.
    • The solution is unique.

    Input

    Input is given from Standard Input in the following format:

    N
    T A
    H1 H2  HN
    

    Output

    Print the index of the place where the palace should be built.


    Sample Input 1

    Copy
    2
    12 5
    1000 2000
    

    Sample Output 1

    Copy
    1
    
    • The average temperature of Place 1 is 12−1000×0.006=6 degrees Celsius.
    • The average temperature of Place 2 is 12−2000×0.006=0 degrees Celsius.

    Thus, the palace should be built at Place 1.

    #include <iostream>
    #include <algorithm>
    #include <cstring>
    #include <cstdio>
    #include <vector>
    #include <queue>
    #include <stack>
    #include <cstdlib>
    #include <iomanip>
    #include <cmath>
    #include <cassert>
    #include <ctime>
    #include <cstdlib>
    #include <map>
    #include <set>
    using namespace std;
    #pragma comment(linker, "/stck:1024000000,1024000000")
    #define lowbit(x) (x&(-x))
    #define max(x,y) (x>=y?x:y)
    #define min(x,y) (x<=y?x:y)
    //#define MAX 100000000000000000
    #define MOD 1000000007
    #define pi acos(-1.0)
    #define ei exp(1)
    #define PI 3.1415926535897932384626433832
    #define ios() ios::sync_with_stdio(true)
    #define INF (1<<31)-1;
    #define mem(a) (memset(a,0,sizeof(a)))
    int main()
    {
        double MAX = INF;
        int N,T,A;
        int pre;
        int deg;
        double result;
        cin>>N;
        cin>>T>>A;
        for(int i=1;i<=N;i++){
            cin>>deg;
            result = abs(A - (T-deg*0.006));
            if(result < MAX){
                MAX = result;
                pre = i;
                //cout<<MAX<<endl;
            }
        }
        cout<<pre<<endl;
        return 0;
    }
  • 相关阅读:
    java格式化sql
    Java 实现对Sql语句解析
    java 解析四则混合运算表达式并计算结果
    SQL转Java代码小工具
    eclipse导入maven工程步骤
    xml文件的schema也是经过jdk编译器编译的,如果xsd没引入完整,而xml中又用到了这些标签,就会编译不通过啊。
    eclipse bug之'<>'operator is not allowed for source level below 1.7
    eclipse默认指定项目的编译器版本
    eclipse导入maven项目后依赖jar包更新问题->update project按钮
    maven也是apache下的项目
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/9906673.html
Copyright © 2011-2022 走看看