题意:有N首歌曲,播放的顺序按照一定的规则,输出前T首被播放的歌的编号。规则如下:

1、每首歌有一个初始的等级r,每次都会播放当前所有歌曲中r最大的那首歌(若r最大的有多首,则播放编号最小的那首歌)。

2、当某首歌被播放完后,它的等级r会变成0,而且它的r会被均分到其他N-1首歌里,若均分后还有剩余,则将剩余的将会分给剩下N-1首歌。(按照这N-1首歌编号从小到大的顺序,每首歌分1个)

3、每播放完一首歌都会执行一遍条件2。

分析:注意N=1时特判,否则除数不能为0。

#pragma comment(linker, "/STACK:102400000, 102400000")
#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 Min(a, b) ((a < b) ? a : b)
#define Max(a, b) ((a < b) ? b : a)
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 = 20000 + 10;
const int MAXT = 10000 + 10;
using namespace std;
struct Node{
int x, id;
bool operator <(const Node&rhs)const{
return x > rhs.x || (x == rhs.x && id < rhs.id);
}
}num[MAXN];
bool cmp(const Node&a, const Node&b){
return a.id < b.id;
}
int main(){
int N, T;
scanf("%d%d", &N, &T);
for(int i = 0; i < N; ++i){
scanf("%d", &num[i].x);
num[i].id = i + 1;
}
if(N == 1){
for(int i = 0; i < T; ++i) printf("1\n");
return 0;
}
while(T--){
sort(num, num + N);
printf("%d\n", num[0].id);
int tmp = num[0].id;
int ave = num[0].x / (N - 1);
int yu = num[0].x % (N - 1);
num[0].x = 0;
for(int i = 1; i < N; ++i){
num[i].x += ave;//它的r会被均分到其他N-1首歌里
}
sort(num, num + N, cmp);
int cnt = 0;
for(int i = 0; ; ++i){
if(cnt == yu) break;
if(tmp != num[i].id){
++num[i].x;
++cnt;
}
}
}
return 0;
}

  

POJ - 3665 iCow(模拟)的更多相关文章

  1. POJ - 3665 icow

    Fatigued by the endless toils of farming, Farmer John has decided to try his hand in the MP3 player ...

  2. POJ 3665 模拟

    按照题意模拟就OK了 //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> ...

  3. poj 3077Rounders(模拟)

    转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents 题目链接:http://po ...

  4. POJ 1068 Parencodings 模拟 难度:0

    http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; ...

  5. POJ 1036 Rails 模拟堆栈

    水题,主要是思路清晰,判断明确. 记x为A站最前方的车,y表示下一列要进入B站的车厢,初识时,x=1;y=a1;C=[]; 在调度过程中: if(y==0)那么调度成功,退出模拟过程:否则 if(x= ...

  6. POJ 1001 Exponentiation 模拟小数幂

    模拟小数幂 小数点位 pos 非零末位 e 长度 len 只有三种情况 pos > len pos < e e < pos < len #include <iostrea ...

  7. POJ 1008 简单模拟题

    e.... 虽然这是一道灰常简单的模拟题.但是米做的时候没有读懂第二个日历的计时方法.然后捏.敲完之后华丽的WA了进一个点.坑点就在一年的最后一天你是该输出本年的.e ...但是我好想并没有..看di ...

  8. Crashing Robots POJ 2632 简单模拟

    Description In a modernized warehouse, robots are used to fetch the goods. Careful planning is neede ...

  9. poj 1806 分块模拟

    Manhattan 2025 Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1318   Accepted: 703 Des ...

随机推荐

  1. 006、MySQL取当前系统时间

    #取当前时间文本格式 SELECT curdate( ) , now( ); 效果如下图: 不忘初心,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码打赏任意金额给作者(微信号:3824772 ...

  2. 【转】转帖并注释:Java中的事件处理机制--事件监听器的四种实现方式

    原文地址:http://blog.sina.com.cn/s/blog_4b650d650100nqws.html Java中四种事件监听器的实现方式分别为: 自身类做为事件监听器 外部类作为事件监听 ...

  3. Win 10 开启FTP与配置

    转载:https://blog.csdn.net/qq_34610293/article/details/79210539 可能出现的问题是:设置共享文件,无法被共享.极大的可能原因是电脑防火墙的问题 ...

  4. Centos 8双网卡设置

    原理:不管开发板是通过直连.路由器还是交换机连接到PC机,最终都是接到PC的以太网网卡(对笔记本来说,一般存在两个网卡,一个WIFI网卡和以太网网卡):因此要实现PC机与虚拟机的互ping,必须把虚拟 ...

  5. Day 29:HTML常用标签

    软件的结构:  cs结构的软件的缺点:更新的时候需要用户下载更新包然后再安装,需要开发客户端与服务端.  cs结构软件的优点: 减轻服务端的压力,而且可以大量保存数据在客户端.  C/S(Client ...

  6. Window Server 2019 配置篇(2)- 在window server core上安装网络跟DHCP服务

    上一篇我们已经建立了自己的域服务器 之后我们将安装一个window server core,也就是没有GUI只有命令行的window server,并在其上安装网络服务和DHCP 首先创建一个新的虚拟 ...

  7. 电脑必须用U盘引导盘才能进系统解决办法

    昨天为了装Ubuntu双系统把系统给装崩了,结果重装win7系统之后出现了以下问题,百度的结果有些杂乱,解决过程自己做一下记录. 问题一:安装程序结束后,出现“Windows安装程序无法将Window ...

  8. CSS - 设置placeholder样式

    input::placeholder {         font-size: 12px;         font-family: Arial;         letter-spacing: 5p ...

  9. mcu运行时间估算

    昨个伙计问我他那个板子的程序运行时间估算问题… 现在说一下估算的思路.首先确定有几个点,板子的主频.时钟周期,机器周期. 首先由主频f得到一个时钟周期为1/f. 再者时钟周期与机器周期有一个比例关系, ...

  10. <强化学习>无模型下计算给定策略对应的价值函数,Model free Prediction,评估一个给定策略的表现

    一.Intro Prediction只是评估给定策略的表现,直白的说它是找 “在环境ENV下,AGENT按照给定的策略pai,AGENT的价值函数”. 这篇blog只介绍三种计算方法,没有涉及到 “求 ...