博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cf(415 A,B)
阅读量:5172 次
发布时间:2019-06-13

本文共 4152 字,大约阅读时间需要 13 分钟。

A. Mashmokh and Lights
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Mashmokh works in a factory. At the end of each day he must turn off all of the lights.

The lights on the factory are indexed from 1 to n. There are n buttons in Mashmokh's room indexed from 1 to n as well. If Mashmokh pushes button with index i, then each light with index not less than i that is still turned on turns off.

Mashmokh is not very clever. So instead of pushing the first button he pushes some of the buttons randomly each night. He pushed mdistinct buttons b1, b2, ..., bm (the buttons were pushed consecutively in the given order) this night. Now he wants to know for each light the index of the button that turned this light off. Please note that the index of button bi is actually bi, not i.

Please, help Mashmokh, print these indices.

Input

The first line of the input contains two space-separated integers n and m (1 ≤ n, m ≤ 100), the number of the factory lights and the pushed buttons respectively. The next line contains m distinct space-separated integers b1, b2, ..., bm (1 ≤ bi ≤ n).

It is guaranteed that all lights will be turned off after pushing all buttons.

Output

Output n space-separated integers where the i-th number is index of the button that turns the i-th light off.

Sample test(s)
input
5 44 3 1 2
output
1 1 3 4 4
input
5 55 4 3 2 1
output
1 2 3 4 5
Note

In the first sample, after pressing button number 4, lights 4 and 5 are turned off and lights 1, 2 and 3 are still on. Then after pressing button number 3, light number 3 is turned off as well. Pressing button number 1 turns off lights number 1 and 2 as well so pressing button number 2 in the end has no effect. Thus button number 4 turned lights 4 and 5 off, button number 3 turned light 3 off and button number 1 turned light 1 and 2 off.

这套题真是考验英语水平。。。。

#include 
#include
#include
#include
#include
#include
using namespace std;typedef long long ll;int a[105],b[105]={0};int main(){ int n,m; cin>>n>>m; for(int i=0;i
>a[i]; for(int j=a[i];j<=n;j++) if(b[j]==0) b[j]=a[i]; else break; } for(int i=1;i<=n;i++) cout<
<<' '; cout<

B. Mashmokh and Tokens
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives backw tokens then he'll get  dollars.

Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save.

Input

The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains nspace-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109).

Output

Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day.

Sample test(s)
input
5 1 412 6 11 9 1
output
0 2 3 1 1
input
3 1 21 2 3
output
1 0 1
input
1 1 11
output
0

读半天题目都没读懂真是醉了。。。。。。。说一下题意:每天得到ai个可以转换钱的东西(可以比喻成银行卡啥的),只不过这个东西只能当天去换钱,不能每天攒到一起了凑整别的天再去换,换得[w*a/b]块钱,方括号表示取整,可是这个人虽然喜欢这个卡,但是毕竟更喜欢money呀!!所以呢,在换得最大钱数的情况下,有一些卡是可以留下来积攒的,所以让我们求每天最多可以积攒多少这种卡?很简单吧!可是读题是硬伤T_T……

#include 
#include
#include
#include
#include
#include
using namespace std;typedef long long ll;ll x;int main(){ int n;ll a,b; cin>>n>>a>>b; for(int i=0;i
>x; ll tem=x*a/b; //cout<

转载于:https://www.cnblogs.com/martinue/p/5490483.html

你可能感兴趣的文章
TFS2018环境搭建一硬件要求
查看>>
GenericFactoryMethod泛型工厂模式实现简单IOC功能
查看>>
spring data jpa方法命名规则
查看>>
Problem Triangle
查看>>
Mysql常用函数
查看>>
Jquery对话框基本配置
查看>>
Delphi之TClientSocket和TServerSocket使用tcp keepalive心跳机制实现“断网”、"断电"检测...
查看>>
Android - 软件自动更新的实现
查看>>
php服务端setcookie()原理
查看>>
iOS - OC NSFileManager 文件管理
查看>>
[CEOI2008]order
查看>>
POJ3155 Hard Life
查看>>
简单的三层框架以及使用dbutils进行数据库操作(入门)
查看>>
java中substring与substr的用法
查看>>
Linux网络编程---htons函数的使用
查看>>
Python 43 视图 、sql注入问题 、事务 、存储过程
查看>>
怎样在Windows 2016 Hyper-V上创建虚拟机
查看>>
Access数据库的增删改查(C#)
查看>>
.net core上传
查看>>
java实现高性能的数据同步
查看>>