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 (思维+模拟)的更多相关文章

  1. CF思维联系--CodeForces -214C (拓扑排序+思维+贪心)

    ACM思维题训练集合 Furik and Rubik love playing computer games. Furik has recently found a new game that gre ...

  2. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  3. CF思维联系--CodeForces - 218C E - Ice Skating (并查集)

    题目地址:24道CF的DIv2 CD题有兴趣可以做一下. ACM思维题训练集合 Bajtek is learning to skate on ice. He's a beginner, so his ...

  4. CF思维联系– CodeForces - 991C Candies(二分)

    ACM思维题训练集合 After passing a test, Vasya got himself a box of n candies. He decided to eat an equal am ...

  5. CF思维联系–CodeForces - 225C. Barcode(二路动态规划)

    ACM思维题训练集合 Desciption You've got an n × m pixel picture. Each pixel can be white or black. Your task ...

  6. CF思维联系–CodeForces -224C - Bracket Sequence

    ACM思维题训练集合 A bracket sequence is a string, containing only characters "(", ")", ...

  7. 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 ...

  8. CF思维联系–CodeForces - 222 C Reducing Fractions(数学+有技巧的枚举)

    ACM思维题训练集合 To confuse the opponents, the Galactic Empire represents fractions in an unusual format. ...

  9. 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 ...

随机推荐

  1. Java第二十八天,Lambda表达式

    一.函数式编程 1.什么是函数式编程 函数式编程是种编程方式,是一种编程的思维,它属于"结构化编程"的一种,主要思想是把运算过程尽量写成一系列嵌套的函数调用.它的地位等同于面向对象 ...

  2. Linux 权限管理篇(一)

    可读        r 可写        w 可执行        x 档案属性: 第一栏:执行list -al后第一栏的十个标志[1 - 10] 1: d    目录 -    档案 l    连 ...

  3. 16-jmeter-CLI模式(无图形界面)

    GUI和非GUI图形界面的使用区别: 非GUI界面:命令模式运行可以将实时的log文件保存到本地,位置可以自定义,不会占用太多资源,可以长时间运行. GUI图形界面:在运行时会消耗资源,且图形界面运行 ...

  4. virtual box设置网络,使用nat网络和仅主机(Host Only)网络进行连接

    virtual box设置网络,使用nat网络和仅主机(Host Only)网络进行连接 前言 作为程序员难免要在本机电脑安装虚拟机,最近在用virtual box安装虚拟机的时候遇到了点问题. 对于 ...

  5. conda命令详解

    显示已有环境信息 conda info --envs 创建环境 conda create --name [环境名] python=[版本号] 删除环境 conda remove --name [环境名 ...

  6. c++缓冲区 vBufferChar.hpp

    //vbuffer_char.hpp //vov #ifndef V_BUFFER_CHAR_HPP #define V_BUFFER_CHAR_HPP #include <iostream&g ...

  7. js数组的遍历(API)

    1.for 循环 普通遍历方法,可优化,存下数组的length,避免每次都去获取数组的length,性能提升 for(var i=0;i<arr.length;i++){ console.log ...

  8. [原创] 在C++中实现打字机效果

    如题. void pout(string str,int t)//随便取的,不要介意,str是待输出字符串,t是每两个字的间隔时间. { ;i<str.length();i++) { cout& ...

  9. 使用Jmeter测试java请求

    1.性能测试过程中,有时候开发想对JAVA代码进行性能测试,Jmeter是支持对Java请求进行性能测试,但是需要自己开发.打包好要测试的代码,就能在Java请求中对该java方法进行性能测试2.本文 ...

  10. 【Java】关键字 和 保留字

    Java的关键字[Keyword]和 保留字[Reserved word] 官方描述: https://docs.oracle.com/javase/tutorial/java/nutsandbolt ...