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

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

Jun 24, 2016 am 11:54 AM

链接:http://codeforces.com/contest/485


A. Factory

time limit per test

1 second

memory limit per test

256 megabytes

One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there werex details in the factory storage, then by the end of the day the factory has to produce (remainder after dividingx bym) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory.

The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible bym).

Given the number of details a on the first day and number m check if the production stops at some moment.

Input

The first line contains two integers a and m (1?≤?a,?m?≤?105).

Output

Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No".

Sample test(s)

Input

1 5
Copy after login

Output

No
Copy after login

Input

3 6
Copy after login

Output

Yes
Copy after login


x每次加上对m取模的值,如果取模为0输出YES,如果值之前出现过,则进入循环输出No退出


#include <cstdio>#include <cstring>int vis[100002];int main(){	int a, m;	scanf("%d %d", &a, &m);	memset(vis, 0, sizeof(vis));	while(true)	{		if(a == 0)		{			printf("Yes\n");			return 0;		}		if(vis[a])		{			printf("No\n");			return 0;		}		vis[a] = 1;		a = (a + a % m) % m;	}}
Copy after login





B. Valuable Resources

time limit per test

1 second

memory limit per test

256 megabytes

Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems.

Let's suppose that your task is to build a square city. The world map uses the Cartesian coordinates. The sides of the city should be parallel to coordinate axes. The map contains mines with valuable resources, located at some points with integer coordinates. The sizes of mines are relatively small, i.e. they can be treated as points. The city should be built in such a way that all the mines are inside or on the border of the city square.

Building a city takes large amount of money depending on the size of the city, so you have to build the city with the minimum area. Given the positions of the mines find the minimum possible area of the city.

Input

The first line of the input contains number n ? the number of mines on the map (2?≤?n?≤?1000). Each of the nextn lines contains a pair of integersxi andyi ? the coordinates of the corresponding mine (?-?109?≤?xi,?yi?≤?109). All points are pairwise distinct.

Output

Print the minimum area of the city that can cover all the mines with valuable resources.

Sample test(s)

Input

20 02 2
Copy after login

Output

Input

20 00 3
Copy after login

Output


给几个点,让这几个点都在一个正方形上或者内部,求正方形的面积的最小值,最上减最下和最右减最左的最大值作为边长


#include <cstdio>#include <algorithm>#define ll long longusing namespace std;int main(){	int n;	ll x, y;	ll mu, md, ml, mr;	ll ans = 0;	mu = mr = -2147483646;	ml = md = 2147483647;	scanf("%d", &n);	for(int i = 0; i < n; i++)	{		scanf("%I64d %I64d", &x, &y);		mu = max(mu , y);		md = min(md , y);		ml = min(ml , x);		mr = max(mr , x);	}	ans = max((mu - md), (mr - ml)) * max((mu - md), (mr - ml));	printf("%I64d\n", ans);}
Copy after login






C. Bits

time limit per test

1 second

memory limit per test

256 megabytes

Let's denote as the number of bits set ('1' bits) in the binary representation of the non-negative integer x.

You are given multiple queries consisting of pairs of integersl andr. For each query, find thex, such thatl?≤?x?≤?r, and is maximum possible. If there are multiple such numbers find the smallest of them.

Input

The first line contains integer n ? the number of queries (1?≤?n?≤?10000).

Each of the following n lines contain two integersli,?ri ? the arguments for the corresponding query (0?≤?li?≤?ri?≤?1018).

Output

For each query print the answer in a separate line.

Sample test(s)

Input

31 22 41 10
Copy after login

Output

137
Copy after login

Note

The binary representations of numbers from 1 to 10 are listed below:

110?=?12

210?=?102

310?=?112

410?=?1002

510?=?1012

610?=?1102

710?=?1112

810?=?10002

910?=?10012

1010?=?10102


给一个区间,求区间里的数转化为二进制后拥有'1'个数最多的那个数,要是拥有'1'的数量相同,取最小的那个数输出。

直接从左端点对1进行或运算,构造出'1'最多且最小的数,直到值大于右端点


#include <cstdio>#define ll long longint main(){	int t;    scanf("%d", &t);      while(t--)    {          ll l, r, tmp, p = 1;           scanf("%I64d %I64d", &l, &r);        for(ll i = 0; i < 63; i++)          {              ll tmp = l | p;             if(tmp > r)            	break;              l = tmp;            p <<= 1;          }          printf("%I64d\n", l);    }  }
Copy after login





D. Maximum Value

time limit per test

1 second

memory limit per test

256 megabytes

You are given a sequence a consisting ofn integers. Find the maximum possible value of (integer remainder ofai divided byaj), where1?≤?i,?j?≤?n and ai?≥?aj.

Input

The first line contains integer n ? the length of the sequence (1?≤?n?≤?2·105).

The second line contains n space-separated integersai (1?≤?ai?≤?106).

Output

Print the answer to the problem.

Sample test(s)

Input

33 4 5
Copy after login

Output


找a[i] < a[j]中a[j] % a[i]的最大值  ,  ai的范围不大,用hash做


#include <cstdio>  int const MAX = 2000000 + 10;  int a[MAX];  int main()  {      int n, x, ans = 0;      scanf("%d",&n);        for(int i = 0; i < n; i++)      {          scanf("%d",&x);          a[x] = x;      }      for(int i = 0; i < MAX; i++)          if(a[i] != i)              a[i] = a[i - 1];      for(int i = 2; i < MAX; i++)            if(a[i] == i)              for(int j = i + i - 1; j < MAX; j = j + i)                  if(a[j] % i > ans && a[j] > i)                      ans = a[j] % i;            printf("%d\n",ans);   } 
Copy after login





Div.1 : D. Kindergarten

time limit per test

2 seconds

memory limit per test

256 megabytes

In a kindergarten, the children are being divided into groups. The teacher put the children in a line and associated each child with his or her integer charisma value. Each child should go to exactly one group. Each group should be a nonempty segment of consecutive children of a line. A group's sociability is the maximum difference of charisma of two children in the group (in particular, if the group consists of one child, its sociability equals a zero).

The teacher wants to divide the children into some number of groups in such way that the totalsociability of the groups is maximum. Help him find this value.

Input

The first line contains integer n ? the number of children in the line (1?≤?n?≤?106).

The second line contains n integersai ? the charisma of thei-th child (?-?109?≤?ai?≤?109).

Output

Print the maximum possible total sociability of all groups.

Sample test(s)

Input

51 2 3 1 2
Copy after login

Output

Input

33 3 3
Copy after login

Output

Note

In the first test sample one of the possible variants of an division is following: the first three children form a group with sociability 2, and the two remaining children form a group with sociability 1.

In the second test sample any division leads to the same result, the sociability will be equal to 0 in each group.


把一串数列分成若干组,每组的权值为该组中最大值与最小值的差,求所有组的权值和的最大值


#include <cstdio>#define ll long longint main(){    int n, t;     scanf ("%d", &n);    ll ans = 0, t1 = 0, t2 = 0;    for(int i = 0; i < n; i++)    {        scanf("%d", &t);        if (!i || ans + t > t1) t1 = ans + t;        if (!i || ans - t > t2) t2 = ans - t;        ans = t1 - t > t2 + t ? t1 - t : t2 + t;    }    printf("%I64d\n", ans);}
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)

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

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.

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the viewport meta tag? Why is it important for responsive design? What is the viewport meta tag? Why is it important for responsive design? Mar 20, 2025 pm 05:56 PM

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

The article discusses the &lt;iframe&gt; tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

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.

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

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.

See all articles