搜索
首页web前端html教程Codeforces Round #240 (Div. 2)_html/css_WEB-ITnose

500pt:

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.


分析:弄一个数组,开始初始化为-1,然后每次开关某light,就把比它大的还是-1的值设为该开关

代码:

#include <vector>#include <list>#include <map>#include <set>#include <deque>#include <stack>#include <bitset>#include <algorithm>#include <functional>#include <numeric>#include <utility>#include <sstream>#include <iostream>#include <iomanip>#include <cstdio>#include <cmath>#include <cstdlib>#include <ctime>using namespace std;typedef long long ll;const int N=100010;int arr[N];int n;int main(){    while(cin>>n)    {        int m;        for(int i=1;i>m;        for(int i=0;i<m int b cin>>b;            for(int j=b;j  <br> 1000pt:  <p></p>  <p></p>  <p class="sycode">   </p>
<p class="sycode">    B. Mashmokh and Tokens   </p>   <p class="sycode">    </p>
<p class="sycode">     time limit per test    </p> 1 second      <p class="sycode">    </p>
<p class="sycode">     memory limit per test    </p> 256 megabytes      <p class="sycode">    </p>
<p class="sycode">     input    </p> standard input      <p class="sycode">    </p>
<p class="sycode">     output    </p> standard output       <p class="sycode">   </p>
<p> 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.</p>   <p> 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.</p>    <p class="sycode">   </p>
<p class="sycode">    Input   </p>   <p> 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 containsn space-separated integers x1,?x2,?...,?xn (1?≤?xi?≤?109).</p>    <p class="sycode">   </p>
<p class="sycode">    Output   </p>   <p> Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day.</p>    <p class="sycode">   </p>
<p class="sycode">    Sample test(s)   </p>   <p class="sycode">    </p>
<p class="sycode">     </p>
<p class="sycode">      input     </p>     <pre class='brush:php;toolbar:false;'>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

分析:数学题,不要理解错题意就行,反正就是不要多拿没用的来token来换钱就行

代码:

#include <stdio.h>int n, a, b, x[100000];int main(){	scanf("%d%d%d", &n, &a, &b);	for(int i = 0; i   <br> 1500pt:  <p></p>  <p></p>  <p class="sycode">   </p>
<p class="sycode">    C. Mashmokh and Numbers   </p>   <p class="sycode">    </p>
<p class="sycode">     time limit per test    </p> 1 second      <p class="sycode">    </p>
<p class="sycode">     memory limit per test    </p> 256 megabytes      <p class="sycode">    </p>
<p class="sycode">     input    </p> standard input      <p class="sycode">    </p>
<p class="sycode">     output    </p> standard output       <p class="sycode">   </p>
<p> It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh.</p>   <p> In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he removes the first and the second integer of the remaining sequence from the board, and so on. Bimokh stops when the board contains less than two numbers. When Bimokh removes numbers x and y from the board, he gets gcd(x,?y) points. At the beginning of the game Bimokh has zero points.</p>   <p> Mashmokh wants to win in the game. For this reason he wants his boss to get exactly k points in total. But the guy doesn't know how choose the initial sequence in the right way.</p>   <p> Please, help him. Find n distinct integers a1,?a2,?...,?an such that his boss will score exactly k points. Also Mashmokh can't memorize too huge numbers. Therefore each of these integers must be at most 109.</p>    <p class="sycode">   </p>
<p class="sycode">    Input   </p>   <p> The first line of input contains two space-separated integers n,?k (1?≤?n?≤?105; 0?≤?k?≤?108).</p>    <p class="sycode">   </p>
<p class="sycode">    Output   </p>   <p> If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1,?a2,?...,?an (1?≤?ai?≤?109).</p>    <p class="sycode">   </p>
<p class="sycode">    Sample test(s)   </p>   <p class="sycode">    </p>
<p class="sycode">     </p>
<p class="sycode">      input     </p>     <pre class='brush:php;toolbar:false;'>5 2

output

1 2 3 4 5

input

5 3

output

2 4 3 7 1

input

7 2

output

-1

Note

gcd(x,?y) is greatest common divisor of x and y.


分析:貌似乱搞搞过了。。。我是先平均每对分担到的k值,然后对于每个k,都用连续的两个值去乘,比如k=4,一共5个数的话,前两队每对得分为2,第一队的两个数为1*2和2*2,第二队的两个数为3*2和4*2,连续的两个数能保证gcd,针对平摊的最后一个k值要特殊处理一下

代码:

#include <vector>#include <list>#include <map>#include <set>#include <deque>#include <stack>#include <bitset>#include <algorithm>#include <functional>#include <numeric>#include <utility>#include <sstream>#include <iostream>#include <iomanip>#include <cstdio>#include <cmath>#include <cstdlib>#include <ctime>#include <string.h>using namespace std;typedef long long ll;const int N=(int)1e9+1;map<int> visited;int n,k;int main(){    cin>>n>>k;    if(n==1)    {        if(k==0)            cout ans;    int t = n/2;    if(t>k)    {        coutN||t2>N)        {            cout  <br> 2000pt:  <p></p>  <p></p>  <p class="sycode">   </p>
<p class="sycode">    D. Mashmokh and ACM   </p>   <p class="sycode">    </p>
<p class="sycode">     time limit per test    </p> 1 second      <p class="sycode">    </p>
<p class="sycode">     memory limit per test    </p> 256 megabytes      <p class="sycode">    </p>
<p class="sycode">     input    </p> standard input      <p class="sycode">    </p>
<p class="sycode">     output    </p> standard output       <p class="sycode">   </p>
<p> Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced programmer. Actually he is not a programmer at all. So he wasn't able to solve them. That's why he asked you to help him with these tasks. One of these tasks is the following.</p>   <p> A sequence of l integers b1,?b2,?...,?bl (1?≤?b1?≤?b2?≤?...?≤?bl?≤?n) is called good if each number divides (without a remainder) by the next number in the sequence. More formally  for all i (1?≤?i?≤?l?-?1).</p>   <p> Given n and k find the number of good sequences of length k. As the answer can be rather large print it modulo 1000000007 (109?+?7).</p>    <p class="sycode">   </p>
<p class="sycode">    Input   </p>   <p> The first line of input contains two space-separated integers n,?k (1?≤?n,?k?≤?2000).</p>    <p class="sycode">   </p>
<p class="sycode">    Output   </p>   <p> Output a single integer ? the number of good sequences of length k modulo 1000000007 (109?+?7).</p>    <p class="sycode">   </p>
<p class="sycode">    Sample test(s)   </p>   <p class="sycode">    </p>
<p class="sycode">     </p>
<p class="sycode">      input     </p>     <pre class='brush:php;toolbar:false;'>3 2

output

input

6 4

output

39

input

2 1

output

Note

In the first sample the good sequences are: [1,?1],?[2,?2],?[3,?3],?[1,?2],?[1,?3].

分析:早知道应该做这题的,连我都会的dp.....用dp[i][j]表示长度为i,最后一个元素为j的序列数

代码:

#include <vector>#include <list>#include <map>#include <set>#include <deque>#include <stack>#include <bitset>#include <algorithm>#include <functional>#include <numeric>#include <utility>#include <sstream>#include <iostream>#include <iomanip>#include <cstdio>#include <cmath>#include <cstdlib>#include <ctime>#include <string.h>using namespace std;typedef long long ll;const int N=2010;const int MOD = (int)1e9+7;int dp[N][N];int n,k;int main(){    while(cin>>n>>k)    {		memset(dp,0,sizeof(dp));		for(int i=1;i  <br>  <br>  <p></p> </string.h></ctime></cstdlib></cmath></cstdio></iomanip></iostream></sstream></utility></numeric></functional></algorithm></bitset></stack></deque></set></map></list></vector>
声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
公众号网页更新缓存难题:如何避免版本更新后旧缓存影响用户体验?公众号网页更新缓存难题:如何避免版本更新后旧缓存影响用户体验?Mar 04, 2025 pm 12:32 PM

公众号网页更新缓存,这玩意儿,说简单也简单,说复杂也够你喝一壶的。你辛辛苦苦更新了公众号文章,结果用户打开还是老版本,这滋味,谁受得了?这篇文章,咱就来扒一扒这背后的弯弯绕绕,以及如何优雅地解决这个问题。读完之后,你就能轻松应对各种缓存难题,让你的用户始终体验到最新鲜的内容。先说点基础的。网页缓存,说白了就是浏览器或者服务器为了提高访问速度,把一些静态资源(比如图片、CSS、JS)或者页面内容存储起来。下次访问时,直接从缓存里取,不用再重新下载,速度自然快。但这玩意儿,也是个双刃剑。新版本上线,

如何使用HTML5表单验证属性来验证用户输入?如何使用HTML5表单验证属性来验证用户输入?Mar 17, 2025 pm 12:27 PM

本文讨论了使用HTML5表单验证属性,例如必需的,图案,最小,最大和长度限制,以直接在浏览器中验证用户输入。

如何高效地在网页中为PNG图片添加描边效果?如何高效地在网页中为PNG图片添加描边效果?Mar 04, 2025 pm 02:39 PM

本文展示了使用CSS为网页中添加有效的PNG边框。 它认为,与JavaScript或库相比,CSS提供了出色的性能,详细介绍了如何调整边界宽度,样式和颜色以获得微妙或突出的效果

HTML5中跨浏览器兼容性的最佳实践是什么?HTML5中跨浏览器兼容性的最佳实践是什么?Mar 17, 2025 pm 12:20 PM

文章讨论了确保HTML5跨浏览器兼容性的最佳实践,重点是特征检测,进行性增强和测试方法。

&lt; datalist&gt;的目的是什么。 元素?&lt; datalist&gt;的目的是什么。 元素?Mar 21, 2025 pm 12:33 PM

本文讨论了html&lt; datalist&gt;元素,通过提供自动完整建议,改善用户体验并减少错误来增强表格。Character计数:159

&gt; gt;的目的是什么 元素?&gt; gt;的目的是什么 元素?Mar 21, 2025 pm 12:34 PM

本文讨论了HTML&lt; Progress&gt;元素,其目的,样式和与&lt; meter&gt;元素。主要重点是使用&lt; progress&gt;为了完成任务和LT;仪表&gt;对于stati

我如何使用html5&lt; time&gt; 元素以语义表示日期和时间?我如何使用html5&lt; time&gt; 元素以语义表示日期和时间?Mar 12, 2025 pm 04:05 PM

本文解释了HTML5&lt; time&gt;语义日期/时间表示的元素。 它强调了DateTime属性对机器可读性(ISO 8601格式)的重要性,并在人类可读文本旁边,增强Accessibilit

&lt; meter&gt;的目的是什么。 元素?&lt; meter&gt;的目的是什么。 元素?Mar 21, 2025 pm 12:35 PM

本文讨论了HTML&lt; meter&gt;元素,用于在一个范围内显示标量或分数值及其在Web开发中的常见应用。它区分了&lt; meter&gt;从&lt; progress&gt;和前

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
2 周前By尊渡假赌尊渡假赌尊渡假赌
仓库:如何复兴队友
4 周前By尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

WebStorm Mac版

WebStorm Mac版

好用的JavaScript开发工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!