Codeforces Round #315 (Div. 2)

网友投稿 679 2022-11-12

Codeforces Round #315 (Div. 2)

Codeforces Round #315 (Div. 2)

【比赛链接】:​​click here~~​​

这次的比赛感觉最没状态了,首先第一题就看了半天,主要是自己没有静下心来读题,以后得注意一下了

Problem_A:

【题意】:

A. Music

time limit per test

memory limit per test

input

output

Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha listens to his favorite songs in a well-known social network InTalk.

Unfortunately, internet is not that fast in the city of Ekaterinozavodsk and the song takes a lot of time to download. But Lesha is quite impatient. The song's duration is T seconds. Lesha downloads the first S seconds of the song and plays it. When the playback reaches the point that has not yet been downloaded, Lesha immediately plays the song from the start (the loaded part of the song stays in his phone, and the download is continued from the same place), and it happens until the song is downloaded completely and Lesha listens to it to the end. For q seconds of real time the Internet allows you to download q - 1

Tell Lesha, for how many times he will start the song, including the very first start.

Input

The single line contains three integers T, S, q (2 ≤ q ≤ 104, 1 ≤ S < T ≤ 105).

Output

Print a single integer — the number of times the song will be restarted.

Sample test(s)

input

5 2 2

output

2

input

5 4 7

output

1

input

6 2 3

output

1

Note

In the first test, the song is played twice faster than it is downloaded, which means that during four first seconds Lesha reaches the moment that has not been downloaded, and starts the song again. After another two seconds, the song is downloaded completely, and thus, Lesha starts the song twice.

In the second test, the song is almost downloaded, and Lesha will start it only once.

In the third sample test the download finishes and Lesha finishes listening at the same moment. Note that song isn't restarted in this case.

【思路】只要知道了-速度:(q-1)/q,我们设ts-完,则有方程: (q - 1) / q * t + s = t 化简得:t / q = (t - s) / (q - 1) 求解得:t = q * s

然后代码就很简单的过了,然后今天发现昨天的居然没有过~~

代码:

#include #include using namespace std;const int N=1e5+10;int num[N];int main(){ int t,s,q; while(cin>>t>>s>>q) { int cnt=0; while(s

Problem_B:

【题意】:

B. Inventory

time limit per test

memory limit per test

input

output

Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inventory number assigned with each item. It is much easier to create a database by using those numbers and keep the track of everything.

During an audit, you were surprised to find out that the items are not numbered sequentially, and some items even share the same inventory number! There is an urgent need to fix it. You have chosen to make the numbers of the items sequential, starting with 1. Changing a number is quite a time-consuming process, and you would like to make maximum use of the current numbering.

You have been given information on current inventory numbers for n items in the company. Renumber items so that their inventory numbers form a permutation of numbers from 1 to n by changing the number of as few items as possible. Let us remind you that a set ofn numbers forms a permutation if all the numbers are in the range from 1 to n, and no two numbers are equal.

Input

The first line contains a single integer n — the number of items (1 ≤ n ≤ 105).

The second line contains n numbers a1, a2, ..., an (1 ≤ ai ≤ 105) — the initial inventory numbers of the items.

Output

Print n

Sample test(s)

input

31 3 2

output

1 3 2

input

42 2 3 3

output

2 1 3 4

input

12

output

1

Note

In the first test the numeration is already a permutation, so there is no need to change anything.

In the second test there are two pairs of equal numbers, in each pair you need to replace one number.

In the third test you need to replace 2 by 1, as the numbering should start from one.

给一个数n, 再给n个数a[i],a[i]中会有重复 或者大于n的数,要求你给出一个1~n的排列。

【思路】用数组标记一下重复出现过的数,将a[i]中大于n 和 小于等于n 且重复的数的编号index记录下来,然后用1~n中没有出现过的数替换掉即可。

代码:

#include using namespace std;const int N=1e5+10;int num[N];bool vis[N];int arr[N];int main(){ int t; while(~scanf("%d",&t)) { memset(vis,false,sizeof(vis)); memset(num,0,sizeof(num)); memset(arr,0,sizeof(arr)); int ll=0; for(int i=0; it) arr[ll++]=i; else if(!vis[num[i]]) vis[num[i]]=true; } int k=0; for(int i=1; i<=t; ++i) { if(!vis[i]) { // cout<<"num[i]= "<

problem c 待补~~

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:2015 Multi-University Training Contest 5
下一篇:静态网页 和 动态网页
相关文章

 发表评论

暂时没有评论,来抢沙发吧~