songs

songs的相关文章

【UVA】1346 - Songs(贪心)

根据题意可以得到,长度小,并且频率低的排到前面,所以设 k = l  / q; 之后sort排序就可以 14128675 1346 Songs Accepted C++ 0.029 2014-09-01 11:30:14 #include <iostream> #include <cstdlib> #include <cstdio> #include <string> #include <cstring> #include <cmath&g

uva 1346 Songs(贪心)

uva 1346 Songs 题目大意:John Doe 是一个著名的DJ,现在他有n首播放个曲, 每首歌曲有识别符key,歌曲长度l,以及播放频率q.想在John Doe 想将磁带上的歌曲重新排列,方便播放,播放所有歌曲有一个复杂度的计算∑(1≤i≤n)q[i] * ( ∑(1≤j≤i)l[j] ), 然后给出S,请输出重新排列后的第S首歌的识别码. 解题思路:贪心. #include<stdio.h> #include<string.h> #include<stdlib.

CodeForces C. Songs Compression

http://codeforces.com/contest/1015/problem/C Ivan has nn songs on his phone. The size of the ii-th song is aiai bytes. Ivan also has a flash drive which can hold at most mm bytes in total. Initially, his flash drive is empty. Ivan wants to copy all n

[Swift Weekly Contest 128]LeetCode1013. 总持续时间可被 60 整除的歌曲 | Pairs of Songs With Total Durations Divisible by 60

In a list of songs, the i-th song has a duration of time[i] seconds. Return the number of pairs of songs for which their total duration in seconds is divisible by 60.  Formally, we want the number of indices i < j with (time[i] + time[j]) % 60 == 0.

Pairs of Songs With Total Durations Divisible by 60 LT1010

In a list of songs, the i-th song has a duration of time[i] seconds. Return the number of pairs of songs for which their total duration in seconds is divisible by 60.  Formally, we want the number of indices i < j with (time[i] + time[j]) % 60 == 0.

UVa 1346 - Songs

题目大意:n张唱片,每张都有长度和频率,要求题目中公式值最小.求一个排序,输出该排序下第m张CD的id. 思路:贪心,长度越长放越后面,频率越低放越后面,所以按len/p去排序即可. #include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;struct CD{ int id; double len; double p;} cd[100000]

UVA - 1346 Songs (贪心+排序)

题意:已知每首歌的标号,长度和播放频率,求一种播放顺序,使得最小,并且输出该播放顺序下第t首歌的标号. 分析: 1.长度越短,播放频率越大的歌排在前面,上式越小. 2.s(i)表示的是当前播放顺序下这首歌是第几个播放. #include<cstdio> #include<cstring> #include<cstdlib> #include<cctype> #include<cmath> #include<iostream> #inc

Leetcode-1013 Pairs of Songs With Total Durations Divisible by 60(总持续时间可被 60 整除的歌曲)

class Solution { public: int numPairsDivisibleBy60(vector<int>& time) { int hash[1501] {0}; for(int i = 0;i < time.size();i ++) { hash[time[i]] ++; } int rnt = 0; for(int i = 1;i < 501;i ++) { int left = 60-i; while(left<0) left += 60;

1013. Pairs of Songs With Total Durations Divisible by 60

time >=1 and <= 500, so sum >= 2 and sum <= 1000 there are 16 numbers in this interval divisible by 60 from 60 to 960, so the problem becomes find the number of pairs with sum of 60...960 class Solution { public int numPairsDivisibleBy60(int[]