zoukankan      html  css  js  c++  java
  • UVA

    题意:已知每首歌的标号,长度和播放频率,求一种播放顺序,使得最小,并且输出该播放顺序下第t首歌的标号。

    分析:

    1、长度越短,播放频率越大的歌排在前面,上式越小。

    2、s(i)表示的是当前播放顺序下这首歌是第几个播放。

    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<cctype>
    #include<cmath>
    #include<iostream>
    #include<sstream>
    #include<iterator>
    #include<algorithm>
    #include<string>
    #include<vector>
    #include<set>
    #include<map>
    #include<stack>
    #include<deque>
    #include<queue>
    #include<list>
    #define lowbit(x) (x & (-x))
    const double eps = 1e-8;
    inline int dcmp(double a, double b){
        if(fabs(a - b) < eps) return 0;
        return a > b ? 1 : -1;
    }
    typedef long long LL;
    typedef unsigned long long ULL;
    const int INT_INF = 0x3f3f3f3f;
    const int INT_M_INF = 0x7f7f7f7f;
    const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
    const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
    const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
    const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
    const int MOD = 1e9 + 7;
    const double pi = acos(-1.0);
    const int MAXN = 70000 + 10;
    const int MAXT = 10000 + 10;
    using namespace std;
    struct Node{
        int id, len;
        double f;
        double k;
        void read(){
            scanf("%d%d%lf", &id, &len, &f);
            k = len / f;
        }
        bool operator < (const Node&rhs)const{
            return k < rhs.k;
        }
    }num[MAXN];
    int main(){
        int n;
        while(scanf("%d", &n) == 1){
            for(int i = 1; i <= n; ++i){
                num[i].read();
            }
            sort(num + 1, num + 1 + n);
            int t;
            scanf("%d", &t);
            printf("%d
    ", num[t].id);
        }
        return 0;
    }
    
  • 相关阅读:
    微信小程序的scheme码
    微信小程序的简单总结(uni-app)
    ES7-ES11新特性
    Promise 总结
    uni-app创建项目及使用 vant-weapp
    vscode 插件整理
    el-upload 组件总结
    从输入URL到页面显示过程中发生了什么
    实验 1:Mininet 源码安装和可视化拓扑工具
    2020软件工程第一次作业
  • 原文地址:https://www.cnblogs.com/tyty-Somnuspoppy/p/7380430.html
Copyright © 2011-2022 走看看