CF--思维练习--CodeForces - 216C - Hiring Staff (思维+模拟)
ACM思维题训练集合
A new Berland businessman Vitaly is going to open a household appliances’ store. All he’s got to do now is to hire the staff.
The store will work seven days a week, but not around the clock. Every day at least k people must work in the store.
Berland has a law that determines the order of working days and non-working days. Namely, each employee must work for exactly n consecutive days, then rest for exactly m days, then work for n more days and rest for m more, and so on. Vitaly doesn’t want to break the law. Fortunately, there is a loophole: the law comes into force on the day when the employee is hired. For example, if an employee is hired on day x, then he should work on days [x, x + 1, …, x + n - 1], [x + m + n, x + m + n + 1, …, x + m + 2n - 1], and so on. Day x can be chosen arbitrarily by Vitaly.
There is one more thing: the key to the store. Berland law prohibits making copies of keys, so there is only one key. Vitaly is planning to entrust the key to the store employees. At the same time on each day the key must be with an employee who works that day — otherwise on this day no one can get inside the store. During the day the key holder can give the key to another employee, if he also works that day. The key will handed to the first hired employee at his first working day.
Each employee has to be paid salary. Therefore, Vitaly wants to hire as few employees as possible provided that the store can operate normally on each day from 1 to infinity. In other words, on each day with index from 1 to infinity, the store must have at least k working employees, and one of the working employees should have the key to the store.
Help Vitaly and determine the minimum required number of employees, as well as days on which they should be hired.
Input
The first line contains three integers n, m and k (1 ≤ m ≤ n ≤ 1000, n ≠ 1, 1 ≤ k ≤ 1000).
Output
In the first line print a single integer z — the minimum required number of employees.
In the second line print z positive integers, separated by spaces: the i-th integer ai (1 ≤ ai ≤ 104) should represent the number of the day, on which Vitaly should hire the i-th employee.
If there are multiple answers, print any of them.
Examples
Input
4 3 2
Output
4
1 1 4 5
Input
3 3 1
Output
3
1 3 5
Sponsor
**这个题之前做过,今天写了1个半小时才写出来,思维真的是不行了。**还是不能落下训练,。

发现直接模拟就能过,想搞点简单wa了N多遍。
思路就是第一天肯定是K个人,直接模拟那K个人休息的M天,让其也保持K人就行,一定要注意第m天结束时一定要有人把钥匙送回第一拨人手上。
#include <bits/stdc++.h>
using namespace std;
int a[10000];
int ans[10000];
int main()
{
int n, m, k;
cin >> n >> m >> k;
if (m <= n - 2)
{
cout << 2 * k << endl;
for (int i = 0; i < k; i++)
printf("1 ");
printf("%d ", n);
n++;
for (int i = 1; i < k; i++)
printf("%d ", n);
puts("");
}
else
{
int cnt = k + 1;
for (int i = 1; i <= m; i++)
{
if (a[i] == k)
continue;
if (a[i] == 0)
{
ans[cnt++] = i - 1;
for (int j = 0; j < n - 1; j++)
a[i + j]++;
}
int w = k - a[i];
for (int j = 0; j < n; j++)
a[i + j] += w;
for (int j = 0; j < w; j++)
ans[cnt++] = i;
}
if (a[m + 1] == 0)
ans[cnt++] = m;
cout << cnt - 1 << endl;
for (int i = 0; i < k; i++)
printf("1 ");
for (int i = k + 1; i < cnt; i++)
printf("%d ", ans[i] + n);
puts("");
}
}
CF--思维练习--CodeForces - 216C - Hiring Staff (思维+模拟)的更多相关文章
- CF思维联系--CodeForces -214C (拓扑排序+思维+贪心)
ACM思维题训练集合 Furik and Rubik love playing computer games. Furik has recently found a new game that gre ...
- CodeForces.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
- CF思维联系--CodeForces - 218C E - Ice Skating (并查集)
题目地址:24道CF的DIv2 CD题有兴趣可以做一下. ACM思维题训练集合 Bajtek is learning to skate on ice. He's a beginner, so his ...
- CF思维联系– CodeForces - 991C Candies(二分)
ACM思维题训练集合 After passing a test, Vasya got himself a box of n candies. He decided to eat an equal am ...
- CF思维联系–CodeForces - 225C. Barcode(二路动态规划)
ACM思维题训练集合 Desciption You've got an n × m pixel picture. Each pixel can be white or black. Your task ...
- CF思维联系–CodeForces -224C - Bracket Sequence
ACM思维题训练集合 A bracket sequence is a string, containing only characters "(", ")", ...
- CF思维联系–CodeForces - 223 C Partial Sums(组合数学的先线性递推)
ACM思维题训练集合 You've got an array a, consisting of n integers. The array elements are indexed from 1 to ...
- CF思维联系–CodeForces - 222 C Reducing Fractions(数学+有技巧的枚举)
ACM思维题训练集合 To confuse the opponents, the Galactic Empire represents fractions in an unusual format. ...
- CF思维联系– CodeForces -CodeForces - 992C Nastya and a Wardrobe(欧拉降幂+快速幂)
Nastya received a gift on New Year - a magic wardrobe. It is magic because in the end of each month ...
随机推荐
- How to setup a Alpine Linux mirror
How to setup a Alpine Linux mirror Contents 1 Introduction 2 Setting up the cron job 3 Setting up ...
- "强调内容"组件:<em> —— 快应用组件库H-UI
 <import name="em" src="../Common/ui/h-ui/text/c_tag_i"></import> & ...
- Struts2-学习笔记系列(5)-配置action
配置包命名空间 实现了action就需要在struts中配置action.首先配置包属性: 需要注意的是:在框架进行包匹配的时候,按文档的从上到下的顺序进行匹配 <!--下面配置名为book ...
- Pytest系列(23)- allure打标记,@allure.feature()、@allure.story()、@allure.severity()的详细使用
如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 前言 前面几篇文章主要介绍了all ...
- TCP的分分合合(面试必问)
TCP连接与断开 目录 TCP连接与断开 前言 握手 挥手 最后 前言 相信面试过的小伙伴对这个话题应该不陌生,算是面试必问了,三次握手,四次挥手,以及其中的一些衍生问题. TCP/IP(Transm ...
- Android | 教你如何在安卓上实现二代身份证识别,一键实名认证
@ 目录 前言 场景 开发前准备 android studio 安装 在项目级gradle里添加华为maven仓 在应用级的build.gradle里面加上SDK依赖 在AndroidManifest ...
- 基于netty实现rpc框架-spring boot客户端
上篇讲了RPC服务端的实现.原理就是解析netty通道数据拿到类.方法及入参等信息,然后通过java反射机制调用本地接口返回结果.没有用到很复杂的技术. 这篇我们将客户端的实现.说白了客户端的任务很简 ...
- sublime查看项目代码多少行
---------------------sublime 0.右击要查找的文件; 1.勾选正则( .* ); 3.输入正则表达式 ^[ \t]*[^ \t\n\r]+.*$ 0:搜索 \n 是不是 ...
- code-breaking picklecode中对signed_cookies引擎分析
最近做了 ph 牛的 code-breaking,在做 picklecode 这一题时,没有搞懂那个 django 的 signed_cookies 引擎对 session 的操作,就 debug 了 ...
- selemiun 问题总结
1.如果打开一个网页定位一个元素时发现不能够定位某一个元素,并且定位的方法没问题,则需要看下该网页是否有frame框架 解决办法: 如果有frame框架则需要先切换到frame框架下: driver. ...