Home Web Front-end HTML Tutorial Codeforces Round #257 (Div. 2)_html/css_WEB-ITnose

Codeforces Round #257 (Div. 2)_html/css_WEB-ITnose

Jun 24, 2016 pm 12:01 PM
round

Orz。。。不吐槽这次比赛了。。。还是太弱了。。


A. Jzzhu and Children

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least ai candies.

Jzzhu asks children to line up. Initially, the i-th child stands at the i-th place of the line. Then Jzzhu start distribution of the candies. He follows the algorithm:

  1. Give m candies to the first child of the line.
  2. If this child still haven't got enough candies, then the child goes to the end of the line, else the child go home.
  3. Repeat the first two steps while the line is not empty.

Consider all the children in the order they go home. Jzzhu wants to know, which child will be the last in this order?

Input

The first line contains two integers n,?m (1?≤?n?≤?100; 1?≤?m?≤?100). The second line contains n integers a1,?a2,?...,?an (1?≤?ai?≤?100).

Output

Output a single integer, representing the number of the last child.

Sample test(s)

input

5 21 3 1 4 2
Copy after login

output

input

6 41 1 2 2 3 3
Copy after login

output

Note

Let's consider the first sample.

Firstly child 1 gets 2 candies and go home. Then child 2 gets 2 candies and go to the end of the line. Currently the line looks like [3, 4, 5, 2] (indices of the children in order of the line). Then child 3 gets 2 candies and go home, and then child 4 gets 2 candies and goes to the end of the line. Currently the line looks like [5, 2, 4]. Then child 5 gets 2 candies and goes home. Then child 2 gets two candies and goes home, and finally child 4 gets 2 candies and goes home.

Child 4 is the last one who goes home.


这道题也就这样。。。


#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>#include<vector>#include<queue>#define INF 0x3f3f3f3fusing namespace std;int main(){    int n, m;    int ans = 0, t = 0, a;    cin >> n >> m;    for (int i = 0; i < n; i++)    {        cin >> a;        if (i == 0 || (a+m-1)/m >= t)        {            ans = i+1;            t = (a+m-1)/m;        }    }    cout << ans << endl;    return 0;}
Copy after login


还有用队列写的。。这个很方便。。

#include <bits/stdc++.h>using namespace std;const int maxn = 1000 + 10;int n, m;struct node{    int id, cd;};int main(){    int i, j;    scanf("%d%d", &n, &m);    queue<node> q;    for(i=1; i<=n; ++i)    {        scanf("%d", &j);        node t;        t.id = i; t.cd = j;        q.push(t);    }    node cur;    while(!q.empty())    {        cur = q.front(); q.pop();        if(cur.cd >m)        {            cur.cd -= m;            q.push(cur);        }    }    printf("%d\n", cur.id);    return 0;}
Copy after login





B. Jzzhu and Sequences

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Jzzhu has invented a kind of sequences, they meet the following property:

You are given x and y, please calculate fn modulo 1000000007 (109? ?7).

Input

The first line contains two integers x and y (|x|,?|y|?≤?109). The second line contains a single integer n (1?≤?n?≤?2·109).

Output

Output a single integer representing fn modulo 1000000007 (109? ?7).

Sample test(s)

input

2 33
Copy after login

output

input

0 -12
Copy after login

output

1000000006
Copy after login

Note

In the first sample, f2?=?f1? ?f3, 3?=?2? ?f3, f3?=?1.

In the second sample, f2?=??-?1; ?-?1 modulo (109? ?7) equals (109? ?6).



B题被人HACK了。。。

原来没考虑好为-1的情况。。淡淡的忧桑。。。。


#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>#include<vector>#include<queue>#define INF 1000000007using namespace std;int main(){    int x, y;    cin>>x>>y;    int n;    cin>>n;    n %= 6;  //6次一循环    int a[10];    a[1]=(x+INF) % INF;    a[2]=(y+INF) % INF;    a[3]=(a[2]-a[1]+INF) % INF;    a[4]=(-x+INF) % INF;    a[5]=(-y+INF) % INF;    a[0]=(a[1]-a[2]+INF) % INF;    n = n%6;    cout<<a[n]<<endl;    return 0;}
Copy after login


C. Jzzhu and Chocolate

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Jzzhu has a big rectangular chocolate bar that consists of n?×?m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements:

  • each cut should be straight (horizontal or vertical);
  • each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate square with cut);
  • each cut should go inside the whole chocolate bar, and all cuts must be distinct.
  • The picture below shows a possible way to cut a 5?×?6 chocolate for 5 times.

    Imagine Jzzhu have made k cuts and the big chocolate is splitted into several pieces. Consider the smallest (by area) piece of the chocolate, Jzzhu wants this piece to be as large as possible. What is the maximum possible area of smallest piece he can get with exactlyk cuts? The area of a chocolate piece is the number of unit squares in it.

    Input

    A single line contains three integers n,?m,?k (1?≤?n,?m?≤?109; 1?≤?k?≤?2·109).

    Output

    Output a single integer representing the answer. If it is impossible to cut the big chocolate k times, print -1.

    Sample test(s)

    input

    3 4 1
    Copy after login

    output

    input

    6 4 2
    Copy after login

    output

    input

    2 3 4
    Copy after login

    output

    -1
    Copy after login

    Note

    In the first sample, Jzzhu can cut the chocolate following the picture below:

    In the second sample the optimal division looks like this:

    In the third sample, it's impossible to cut a 2?×?3 chocolate 4 times.



    #include<cstdio>#include<cstring>#include<algorithm>#include<iostream>#include<vector>#include<queue>#define INF 0x3f3f3f3fusing namespace std;long long int n, m, k;long long int i;int main(){	cin >> n >> m >>k;	if( k>n+m-2 )	{		cout << "-1"<<endl;		return 0;	}	long long int a=0, b=0;	for(i=0; i<2; swap(n,m))	{		if( k<n-1 )			a = (n/(k+1))*m;		else			a = m/(k-n+2);		if( a>=b )			b = a;		i++;	}	cout << b << endl;	return 0;}
    Copy after login



    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

    HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

    The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

    HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

    Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

    WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

    Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

    GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

    What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

    AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

    How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? Apr 05, 2025 am 06:15 AM

    To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

    HTML, CSS, and JavaScript: Essential Tools for Web Developers HTML, CSS, and JavaScript: Essential Tools for Web Developers Apr 09, 2025 am 12:12 AM

    HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

    How to implement adaptive layout of Y-axis position in web annotation? How to implement adaptive layout of Y-axis position in web annotation? Apr 04, 2025 pm 11:30 PM

    The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...

    See all articles