목차
A. Playing with Paper
Code:
B. Error Correct System
C. Glass Carving
데이터 베이스 MySQL 튜토리얼 第三十次codeforces竞技结束 #296 Div 2

第三十次codeforces竞技结束 #296 Div 2

Jun 07, 2016 pm 03:07 PM
div 마치다

Problems # Name A Playing with Paper standard input/output 2 s, 256 MB x2429 B Error Correct System standard input/output 2 s, 256 MB x953 C Glass Carving standard input/output 2 s, 256 MB x584 第三十次……好想到紫啊好想紫55555,两个1A,14

Problems

第三十次codeforces竞技结束 #296 Div 2

 

 

# Name    
A

Playing with Paper

standard input/output

2 s, 256 MB
第三十次codeforces竞技结束 #296 Div 2 第三十次codeforces竞技结束 #296 Div 2 第三十次codeforces竞技结束 #296 Div 2 x2429
B

Error Correct System

standard input/output

2 s, 256 MB
第三十次codeforces竞技结束 #296 Div 2 第三十次codeforces竞技结束 #296 Div 2 第三十次codeforces竞技结束 #296 Div 2 x953
C

Glass Carving

standard input/output

2 s, 256 MB
第三十次codeforces竞技结束 #296 Div 2 第三十次codeforces竞技结束 #296 Div 2 第三十次codeforces竞技结束 #296 Div 2 x584

第三十次……好想到紫啊好想紫55555,两个1A,14min,然后我看Standing的时候你们造么! 28名啊!!!

然后被C骗住了,我以为是zkw线段树……居然是考察数据结构set的问题……

然后……Failed System Test…… 原因?



A. Playing with Paper

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular a mm ?×? bmm sheet of paper (a?>?b). Usually the first step in making an origami is making a square piece of paper from the rectangular sheet by folding the sheet along the bisector of the right angle, and cutting the excess part.

第三十次codeforces竞技结束 #296 Div 2

After making a paper ship from the square piece, Vasya looked on the remaining (a?-?b) mm ?×? b mm strip of paper. He got the idea to use this strip of paper in the same way to make an origami, and then use the remainder (if it exists) and so on. At the moment when he is left with a square piece of paper, he will make the last ship from it and stop.

Can you determine how many ships Vasya will make during the lesson?

Input

The first line of the input contains two integers ab (1?≤?b?a?≤?1012) — the sizes of the original sheet of paper.

Output

Print a single integer — the number of ships that Vasya will make.

Sample test(s)

input

2 1
로그인 후 복사

output

2
로그인 후 복사

input

10 7
로그인 후 복사

output

6
로그인 후 복사

input

1000000000000 1
로그인 후 복사

output

1000000000000
로그인 후 복사

Note

Pictures to the first and second sample test.

第三十次codeforces竞技结束 #296 Div 2


说一张长方形的纸~,每次都以较短边为边长裁一个正方形下来折个纸船,问长宽已知的长方形纸能折多少个纸船。

我想说……做题的时候有这个图么!!!

每次如果裁剪的效果没有达到a的剩余部分

其实看到这个图大家应该就立马懂了,每次不要一裁裁一个正方形,咱们要裁一串,就是 a/b 个。

Code:

#include <cmath> 
#include <cctype>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a) b;
}

int main()
{
	long long a=0,b=0,c=0,t=0;
	cin>>a>>b;
	while(a!=b)
	{
		if(a%b)
		{
			c+=(a/b);
			a=a%b;
			t=a;
			a=b;
			b=t;
		}
		else
		{
			c+=(a/b);
			a=b;
		}
	}
	cout<br>

<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<h2 id="B-Error-Correct-System">B. Error Correct System</h2>
<p>
</p>
<p>
time limit per test</p>
2 seconds
<p>
</p>
<p>
memory limit per test</p>
256 megabytes
<p>
</p>
<p>
input</p>
standard input
<p>
</p>
<p>
output</p>
standard output

<p>
</p>
<p>
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings <span><em>S</em></span> and <span><em>T</em></span> of
 equal length to be "similar". After a brief search on the Internet, he learned about the<span>Hamming distance</span> between two strings <span><em>S</em></span> and <span><em>T</em></span> of
 the same length, which is defined as the number of positions in which <span><em>S</em></span> and <span><em>T</em></span> have
 different characters. For example, the Hamming distance between words "<span>permanent</span>" and "<span>pergament</span>"
 is two, as these words differ in the fourth and sixth letters.</p>
<p>
Moreover, as he was searching for information, he also noticed that modern search engines have powerful mechanisms to correct errors in the request to improve the quality of search. Ford doesn't know much about human beings, so he assumed that the most common
 mistake in a request is swapping two arbitrary letters of the string (not necessarily adjacent). Now he wants to write a function that determines which two letters should be swapped in string<span><em>S</em></span>,
 so that the Hamming distance between a new string <span><em>S</em></span> and string <span><em>T</em></span> would
 be as small as possible, or otherwise, determine that such a replacement cannot reduce the distance between the strings.</p>
<p>
Help him do this!</p>

<p>
</p>
<p>
Input</p>
<p>
The first line contains integer <span><em>n</em></span> (<span>1?≤?<em>n</em>?≤?200?000</span>)
 — the length of strings <span><em>S</em></span> and <span><em>T</em></span>.</p>
<p>
The second line contains string <span><em>S</em></span>.</p>
<p>
The third line contains string <span><em>T</em></span>.</p>
<p>
Each of the lines only contains <span>lowercase</span> Latin letters.</p>

<p>
</p>
<p>
Output</p>
<p>
In the first line, print number <span><em>x</em></span> — the minimum possible Hamming distance between strings <span><em>S</em></span> and <span><em>T</em></span> if
 you swap at most one pair of letters in <span><em>S</em></span>.</p>
<p>
In the second line, either print the indexes <span><em>i</em></span> and <span><em>j</em></span> (<span>1?≤?<em>i</em>,?<em>j</em>?≤?<em>n</em></span>, <span><em>i</em>?≠?<em>j</em></span>),
 if reaching the minimum possible distance is possible by swapping letters on positions <span><em>i</em></span> and <span><em>j</em></span>,
 or print "<span>-1 -1</span>", if it is not necessary to swap characters.</p>
<p>
If there are multiple possible answers, print any of them.</p>

<p>
</p>
<p>
Sample test(s)</p>
<p>
</p>
<p>
</p>
<p>
input</p>
<pre class="brush:php;toolbar:false">9
pergament
permanent
로그인 후 복사

output

1
4 6
로그인 후 복사

input

6
wookie
cookie
로그인 후 복사

output

1
-1 -1
로그인 후 복사

input

4
petr
egor
로그인 후 복사

output

2
1 2
로그인 후 복사

input

6
double
bundle
로그인 후 복사

output

2
4 1
로그인 후 복사

Note

In the second test it is acceptable to print i?=?2j?=?3.


所谓海明距离,就是字符串s和字符串t字符不同的位置个数,比如acm和acg,有一个字符不同,所以是1.

题目问,如果最多允许把s中的两个不同位置的字符调换位置,那么调换后(也可以不调换)海明距离最小是多少。

假设原先海明距离是k,不调换肯定依然是k,调换的话如果要比k小只有2种情况:

1)[s]A [t]B 和某处的[s]B [t]A 调换位置,那么有两个不同处被解决了,即海明距离小了2个,最小为k-2.

2)[s]A [t]B 和某处的[s]B [t]C 调换位置,或

[s]A [t]B 和某处的[s]C [t]A 调换位置, 那么有一个不同处被解决了,即海明距离小了2个,最小为k-1.

那么,该怎么写呢?

由于字符的不同处可多可少,感觉如果全都消耗时间空间比较浪费所以我使用的是map,有的就放进来,读的过程中还可以同时把海明距离数出来,这是O(n)。

用map找由于其本质是红黑树,所以是在O(lgn)的时间内寻找到,综合来看最坏情况也是nlgn,可行。

Code:

#include <map>
#include <cmath> 
#include <cctype>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<char> pcc;
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a) b;
}

map <pcc> mpi;
map <char> mci,mcii;

int main()
{
	int flag=0,x=-1,y=-1;
	int n=0,cnt=0;	cin>>n;
	string s,t;	cin>>s>>t;
	mpi.clear(); mci.clear(); mcii.clear();
	for(int i=0;i<n if cnt mpi flag="2,x=mpi[make_pair(t[i],s[i])],y=i+1;" mci forget a half god... mcii cout return><br>
<br>


<p>
</p>
<h2 id="C-Glass-Carving">C. Glass Carving</h2>
<p>
</p>
<p>
time limit per test</p>
2 seconds
<p>
</p>
<p>
memory limit per test</p>
256 megabytes
<p>
</p>
<p>
input</p>
standard input
<p>
</p>
<p>
output</p>
standard output

<p>
</p>
<p>
Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular <span><em>w</em></span> mm <span>?×?</span> <span><em>h</em></span> mm
 sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of what to carve and how.</p>
<p>
In order not to waste time, he decided to practice the technique of carving. To do this, he makes vertical and horizontal cuts through the entire sheet. This process results in making smaller rectangular fragments of glass. Leonid does not move the newly made
 glass fragments. In particular, a cut divides each fragment of glass that it goes through into smaller fragments.</p>
<p>
After each cut Leonid tries to determine what area the largest of the currently available glass fragments has. Since there appear more and more fragments, this question takes him more and more time and distracts him from the fascinating process.</p>
<p>
Leonid offers to divide the labor — he will cut glass, and you will calculate the area of the maximum fragment after each cut. Do you agree?</p>

<p>
</p>
<p>
Input</p>
<p>
The first line contains three integers <span><em>w</em>,?<em>h</em>,?<em>n</em></span> (<span>2?≤?<em>w</em>,?<em>h</em>?≤?200?000</span>, <span>1?≤?<em>n</em>?≤?200?000</span>).</p>
<p>
Next <span><em>n</em></span> lines contain the descriptions of the cuts. Each description has the form <span><em>H y</em></span> or <span><em>V x</em></span>.
 In the first case Leonid makes the horizontal cut at the distance <span><em>y</em></span> millimeters (<span>1?≤?<em>y</em>?≤?<em>h</em>?-?1</span>)
 from the lower edge of the original sheet of glass. In the second case Leonid makes a vertical cut at distance <span><em>x</em></span> (<span>1?≤?<em>x</em>?≤?<em>w</em>?-?1</span>)
 millimeters from the left edge of the original sheet of glass. It is guaranteed that Leonid won't make two identical cuts.</p>

<p>
</p>
<p>
Output</p>
<p>
After each cut print on a single line the area of the maximum available glass fragment in mm<span><span>2</span></span>.</p>

<p>
</p>
<p>
Sample test(s)</p>
<p>
</p>
<p>
</p>
<p>
input</p>
<pre class="brush:php;toolbar:false">4 3 4
H 2
V 2
V 3
V 1
로그인 후 복사

output

8
4
4
2
로그인 후 복사

input

7 6 5
H 4
V 3
V 5
H 2
V 1
로그인 후 복사

output

28
16
12
6
4
로그인 후 복사

Note

Picture for the first sample test:

第三十次codeforces竞技结束 #296 Div 2
Picture for the second sample test:
第三十次codeforces竞技结束 #296 Div 2
 

有一块大大的玻璃~~~

每次横着或者竖着砍一刀,砍完不要拿走,下一道也得砍到这条线所在的所有部件。

每次砍完之后输出当前碎片中最大面积的部件的面积。

首先要知道的是,千万别一个一个部件的比较面积大小哦,因为每刀都是垂直或者水平的,所以每部分的面积都等于所对应的长边线段和短边线段的积。

即:我们要求的其实只是长边上的最长线段和短边上的最长线段,输出它们的积。

嘛,也顺带用两个例程说明下这三个函数的使用方法吧~ 毕竟set感觉并不是那么太常见(灵活使用的大大们请无视这句^_^)

// erasing from multiset
#include <iostream>
#include <set>

int main ()
{
  std::multiset<int> mymultiset;
  std::multiset<int>::iterator it;

  // insert some values:
  mymultiset.insert (40);                            // 40
  for (int i=1; i<br>
<pre class="brush:php;toolbar:false">// set::find
#include <iostream>
#include <set>

int main ()
{
  std::set<int> myset;
  std::set<int>::iterator it;

  // set some initial values:
  for (int i=1; i<br>
<pre class="brush:php;toolbar:false">// set::insert (C++98)
#include <iostream>
#include <set>

int main ()
{
  std::set<int> myset;
  std::set<int>::iterator it;
  std::pair<:set>::iterator,bool> ret;

  // set some initial values:
  for (int i=1; i<br>
说完了函数的使用方法,嘛,就来看看这题的解题Code吧
<h3 id="Code">Code:</h3>
<pre class="brush:php;toolbar:false">#include <set>
#include <cmath> 
#include <cctype>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define i insert

char ch;
int n,w,h,t;
set<int> x,y,*s;
set<int>::iterator l,r;
multiset<int> lx,ly,*ls;

int main()
{
	cin>>w>>h>>n; x.i(0);x.i(w);y.i(0);y.i(h);lx.i(w);ly.i(h);
    for (int j=1; j>ch>>t;
        if (ch=='H') 
		{s=&y; ls=&ly;} 
		else 
		{s=&x; ls=&lx;}
		s->i(t); l=r=s->find(t); l--; r++; 
		ls->erase(ls->find(*r-*l));
		ls->i(t-*l);
		ls->i(*r-t);
		cout<br>
<br>

<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>


</int></int></int></algorithm></iostream></cstring></cstdlib></string></cstdio></cctype></cmath></set>
로그인 후 복사
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Teamfight Tactics S11은 언제 종료되나요? Teamfight Tactics S11은 언제 종료되나요? Mar 18, 2024 pm 03:16 PM

Teamfight Tactics의 각 시즌은 약 3개월 동안 진행됩니다. 현재 Teamfight Tactics S11 시즌의 미국 테스트 서버는 3월 7일에 업데이트되어 출시될 예정입니다. Teamfight Tactics와 Golden Shovel은 3월 21일에 업데이트되어 출시될 예정입니다. 시즌 아마도 7월 초에 끝날 것 같습니다. TFT S11은 언제 종료되나요? 답변: 7월 초. 1. S11 시즌이 7월 초에 종료될 것으로 예상되며, 구체적인 종료일은 공식 발표를 기다려봐야 할 것 같습니다. 2. Teamfight Tactics의 각 시즌은 약 3개월 동안 지속됩니다. 3. Teamfight Tactics S11 시즌의 미국 테스트 서버는 3월 7일에 업데이트되어 출시될 예정이며, Teamfight Tactics와 Golden Shovel은 3월 21일에 업데이트되어 출시될 예정입니다. 4. S11 시즌에는 새로운 게임플레이 메커니즘이 추가되고, 20개 이상의 오른 아티팩트가 추가됩니다.

Win11 백그라운드에서 실행되는 단축키를 빠르게 끄는 방법은 무엇입니까? Win11 백그라운드에서 실행되는 단축키를 빠르게 끄는 방법은 무엇입니까? Dec 28, 2023 am 09:54 AM

컴퓨터를 사용하다 보면 필연적으로 백그라운드에서 계속 실행되어 시스템 속도가 느려지는 문제가 많이 발생하게 되는데, 이때 win11에서 백그라운드 실행을 종료할 수 있는 단축키가 과연 있을까요? 단축키를 사용하여 작업 관리자를 닫은 다음 Backstage를 닫습니다. win11에서 백그라운드 실행을 종료하는 단축키: 1. 먼저 키보드의 "ctrl+shift+esc" 단축키 조합을 눌러 작업 관리자 페이지를 엽니다. 2. 작업 관리자 페이지에서 마우스를 사용하여 "이름" 버튼 옵션을 클릭하고 선택합니다. 3. 페이지 이동 후 현재 실행 중인 모든 "백그라운드 프로세스"를 직접 볼 수 있습니다. 4. 실제 필요에 따라 닫으려는 배경을 선택하고 옵션 오른쪽 하단에 있는 "작업 끝내기"를 클릭합니다.

컴퓨터 작업 관리자 바로 가기 키를 사용하여 작업을 종료하는 방법 컴퓨터 작업 관리자 바로 가기 키를 사용하여 작업을 종료하는 방법 Jan 02, 2024 pm 01:34 PM

많은 친구들이 컴퓨터를 사용할 때 특정 소프트웨어가 멈추는 현상을 경험합니다. 컴퓨터가 움직일 수 없으면 작업 관리자를 불러와 작업을 종료해야 합니다. 작업을 호출한 후 단축키를 사용하여 작업을 종료하는 방법이 가장 쉬운데, 다른 방법도 살펴보겠습니다. 아래를 살펴보세요. 작업 관리자에서 작업을 종료하기 위한 단축키를 사용하는 방법 작업 관리자에서 단축키를 사용하는 방법: 1. 키 조합 "Ctrl+Shift+ESC". 2. 키 조합 "Ctrl+Alt+Delete". 작업 종료 단축키 1. 종료할 작업을 선택하고 '삭제'를 클릭하세요. 2. 종료해야 하는 작업을 선택하고 "alt+e" 키 조합을 누르십시오.

Tencent Meeting에서 회의를 종료하는 방법 - Tencent Meeting에서 회의를 종료하기 위한 특정 작업 Tencent Meeting에서 회의를 종료하는 방법 - Tencent Meeting에서 회의를 종료하기 위한 특정 작업 Mar 05, 2024 pm 12:16 PM

사무실에서 Tencent Meeting 소프트웨어를 자주 사용하시나요? 그렇다면 Tencent Meeting에서 회의를 종료하는 방법을 아시나요? 다음으로 편집자가 Tencent Meeting에서 회의를 종료하는 구체적인 방법을 알려드리겠습니다. 아래를 살펴보겠습니다. 컴퓨터를 켜고 두 번 클릭하여 Tencent Meeting에 입장한 다음 로그인하고 클릭하여 빠른 회의에 입장한 다음 회의 종료 버튼을 클릭합니다.

CSS를 사용하여 div에 모서리가 누락되었음을 인식하는 방법 CSS를 사용하여 div에 모서리가 누락되었음을 인식하는 방법 Jan 30, 2023 am 09:23 AM

div에 모서리가 없음을 인식하는 CSS 방법: 1. HTML 샘플 파일을 만들고 div를 정의합니다. 2. div의 너비와 높이 배경색을 설정합니다. 3. 삭제해야 하는 div에 의사 클래스를 추가합니다. 모서리를 지정하고 의사 클래스를 배경색과 동일한 색상 사용으로 설정한 다음 45도 회전한 다음 제거해야 할 모서리에 배치합니다.

ChatGPT API를 기반으로 한 단어 표시 번역 브라우저 스크립트 구현 ChatGPT API를 기반으로 한 단어 표시 번역 브라우저 스크립트 구현 May 01, 2023 pm 03:28 PM

머리말 최근에는 GitHub에 ChatGPTAPI 기반의 브라우저 스크립트인 openai-translator가 있습니다. 단기간 내에 번역 지원 외에도 다듬기 및 요약 기능도 지원됩니다. -ins, 또한 Tauri 패키징을 사용합니다. Tauri가 Rust 부분을 사용한다는 사실을 제외하면, 브라우저 부분은 여전히 ​​수동으로 구현하기가 쉽습니다. 예를 들어 openAI에서 제공하는 인터페이스에서는 다음 코드를 복사하고 브라우저 콘솔에서 요청을 시작하여 번역을 완료할 수 있습니다. //예제 constOPENAI_API_KEY="s

iframe과 div의 차이점은 무엇입니까 iframe과 div의 차이점은 무엇입니까 Aug 28, 2023 am 11:46 AM

iframe과 div의 차이점은 iframe은 주로 다른 웹사이트의 콘텐츠를 로드하거나 웹페이지를 여러 영역으로 나눌 수 있는 외부 콘텐츠를 도입하는 데 사용된다는 점입니다. 레이아웃 및 스타일 제어를 위해 콘텐츠를 구성합니다.

div 상자 모델은 무엇입니까 div 상자 모델은 무엇입니까 Oct 09, 2023 pm 05:15 PM

div 상자 모델은 웹 페이지 레이아웃에 사용되는 모델입니다. 이 모델은 콘텐츠 영역, 패딩, 테두리 및 여백의 네 부분으로 구성됩니다. div 박스 모델의 장점은 웹 페이지의 레이아웃과 요소 사이의 간격을 쉽게 제어할 수 있다는 것입니다. 콘텐츠 영역의 크기, 내부 여백, 테두리 및 외부 여백을 조정하여 다양한 레이아웃 효과를 얻을 수 있습니다. 상자 모델은 또한 일부 속성을 제공하며 메서드는 CSS 및 JavaScript를 통해 상자의 스타일과 동작을 동적으로 변경할 수 있습니다.

See all articles