日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CF--思维练习--CodeForces - 216C - Hiring Staff (思维+模拟)

發(fā)布時(shí)間:2023/12/15 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CF--思维练习--CodeForces - 216C - Hiring Staff (思维+模拟) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

ACM思維題訓(xùn)練集合
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
**這個(gè)題之前做過,今天寫了1個(gè)半小時(shí)才寫出來,思維真的是不行了。**還是不能落下訓(xùn)練,。

發(fā)現(xiàn)直接模擬就能過,想搞點(diǎn)簡(jiǎn)單wa了N多遍。
思路就是第一天肯定是K個(gè)人,直接模擬那K個(gè)人休息的M天,讓其也保持K人就行,一定要注意第m天結(jié)束時(shí)一定要有人把鑰匙送回第一撥人手上。

#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("");} }

總結(jié)

以上是生活随笔為你收集整理的CF--思维练习--CodeForces - 216C - Hiring Staff (思维+模拟)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。