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. Centos7如何安装MySQL

    参考博文: 1.安装 https://blog.csdn.net/qq_36582604/article/details/80526287 2.改密码 https://blog.csdn.net/we ...

  2. wireshark抓包实战(二),第一次抓包

    1.选择网卡. 因为wireshark是基于网卡进行抓包的,所以这时候我们必须选取一个网卡进行抓包.选择网卡一般有三种方式 (1)第一种 当我们刚打开软件是会自动提醒您选择,例如: (2)第二种 这时 ...

  3. C语言输出 1到20 的阶乘之和

    除了调用库,绝对找不到比这更精简的代码了. #include<stdio.h> #include<string.h> long long getdata(long long n ...

  4. Linux C++ 网络编程学习系列(5)——多路IO之epoll边沿触发

    多路IO之epoll边沿触发+非阻塞 源码地址:https://github.com/whuwzp/linuxc/tree/master/epoll_ET_LT_NOBLOCK_example 源码说 ...

  5. 用Jenkins集成ios项目设置多scheme,同一代码自动输出多个环境包 实现便捷切换API环境

    Jenkins 安装使用参考我的博客http://www.cnblogs.com/zhujin/p/9064820.html Xcode 配置:说明 一个schema 对应一套环境(如生产,测试),一 ...

  6. A - Engines Atcoder 4900

    题目大意:n个点,任意几个点组合后得到的点距离原点的最远距离. 题解:极角排序:https://blog.csdn.net/qq_39942341/article/details/79840394 利 ...

  7. 如何将SqlServer配置为django的数据源(2.2以后版本)

    django-pyodbc-azure 是一个官方推荐的 第三方django数据库支持backend. 根据官网的介绍django-pyodbc-azure 只能支持到 django 2.1.如果涉及 ...

  8. 【翻译】借助 NeoCPU 在 CPU 上进行 CNN 模型推理优化

    本文翻译自 Yizhi Liu, Yao Wang, Ruofei Yu.. 的  "Optimizing CNN Model Inference on CPUs" 原文链接: h ...

  9. Flutter环境安装,ios真机调试

    MAC: 下载Flutter,官网的可能很慢.可以去我的网盘下载, 提取码: 3t6y. 下载完的包会在~/Downloads目录下,我们移到~/opt/flutter目录下. mkdir ./opt ...

  10. 常见的Web源码泄漏漏洞及其利用

    Web源码泄露的漏洞: git源码泄露 svn源码泄露 hg源码泄漏 网站备份压缩文件 WEB-INF/web.xml 泄露 DS_Store 文件泄露 SWP 文件泄露 CVS泄露 Bzr泄露 Gi ...