찾다
데이터 베이스MySQL 튜토리얼Codeforces Round #231 (Div. 2)

Problems # Name A Counting Sticks standard input/output 1 s, 256 MB x2326 B Very Beautiful Number standard input/output 1 s, 256 MB x856 C Dominoes standard input/output 2 s, 256 MB x803 D Physical Education and Buns standard input/output

Problems

Codeforces Round #231 (Div. 2)

 

 

# Name    
A

Counting Sticks

standard input/output

1 s, 256 MB
Codeforces Round #231 (Div. 2) Codeforces Round #231 (Div. 2) Codeforces Round #231 (Div. 2) x2326
B

Very Beautiful Number

standard input/output

1 s, 256 MB
Codeforces Round #231 (Div. 2) Codeforces Round #231 (Div. 2) Codeforces Round #231 (Div. 2) x856
C

Dominoes

standard input/output

2 s, 256 MB
Codeforces Round #231 (Div. 2) Codeforces Round #231 (Div. 2) Codeforces Round #231 (Div. 2) x803
D

Physical Education and Buns

standard input/output

2 s, 256 MB
Codeforces Round #231 (Div. 2) Codeforces Round #231 (Div. 2) Codeforces Round #231 (Div. 2) x234
E

Lightbulb for Minister

standard input/output

1 s, 256 MB
Codeforces Round #231 (Div. 2) Codeforces Round #231 (Div. 2) Codeforces Round #231 (Div. 2) x49

A题:先处理字符串把3个位置的数字保存下来,在去判断相等或者差值为2,去移动即可。

B题:枚举最后一位数字,模拟往前推数字,推到第一位判断是不是和一开始枚举的数字相同。

C题:贪心,10和01其实是一样的,所以先保存下11,10和01的总数,00的个数,先从左往右放11,放完之后,在从右边往左边去放10,01,每行交替着放即可,剩下的就是00。

D题:从小到大排序后,先枚举公差d,先变化后的序列A1是0,然后求出整个需要去向上移动的最大值和最小值(可能是负的),那么变化后的序列其实可以看成一条斜率k是d,b是A1的直线,然后这条直线无论上移下移,那么对于最大值和最小值肯定还是原来那2个位置,那么只要保证移动到最大值和最小值中的最大值尽可能小,那么就是去中间肯定是最优的,为(up + down + 1)/2  (要向上取整所以+1),最后维护ans的最小值即可。

D题:还有一种解法,二分答案,然后去判断,判断的方式先枚举公差,在用O(n)的方法去维护每个上下区间从大到小。

代码:

A题:

#include <stdio.h>
#include <string.h>

char c;

int main() {
    int num[3], s = 0; 
    memset(num, 0, sizeof(num));
    while ((c = getchar()) != EOF && c != '\n') {
        if (c == '+' || c == '=') s++;
        else num[s]++;
    }
    if (num[0] - 1 + num[1] == num[2] + 1) {
        if (num[0] == 1) num[1]--;
        else if (num[1] == 1) num[0]--;
        else if (num[0] != 1 && num[1] != 1) num[0]--;
        num[2]++;
    }
    else if (num[0] + num[1] == num[2]) {
    
    }
    else if (num[0] + 1 + num[1] == num[2] - 1) {
        if (num[2] == 1) {
            printf("Impossible\n");
            return 0;
        }
        num[2]--;
        num[0]++;
    }
    else {
        printf("Impossible\n");
        return 0;
    }
    int i;
    for (i = 0; i <br>
B题:

<pre class="brush:php;toolbar:false">#include <stdio.h>
#include <string.h>

int p, x, ans[1000005];

int main() {
    scanf("%d%d", &p, &x);
    int yu = 0;
    for (int i = 0; i = 0; j--)
                printf("%d", ans[j]);
            printf("\n");
            return 0;
        }
    }
    printf("Impossible\n");
    return 0;
}</string.h></stdio.h>

C题:

#include <stdio.h>
#include <string.h>

int n, m, i, j;
int num10, num00, num11;
char str[10], ans[1005][1005][4];

int main() {
    num10 = num00 = num11 = 0;
    scanf("%d%d", &n, &m);
    for (i = 0; i <br>
D题1:


<pre class="brush:php;toolbar:false">#include <stdio.h>
#include <string.h>
#include <algorithm>
#define INF 0x3f3f3f3f
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a) res) {
            ans = res; start = -up + res; dd = d;
        }
    }
    printf("%d\n%d %d\n", ans, start, dd);
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i <br>
D题2:<br>

<pre class="brush:php;toolbar:false">#include <stdio.h>
#include <string.h>
#include <algorithm>
#define INF 0x3f3f3f3f
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)= 0; i--) {
			up = min(num[i] + Max, up - d);
			down = max(num[i] - Max, down - d);
		}
		if (down <br>
<br>


</algorithm></string.h></stdio.h>
성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
MySQL에서 기존보기를 삭제하거나 수정하려면 어떻게해야합니까?MySQL에서 기존보기를 삭제하거나 수정하려면 어떻게해야합니까?May 16, 2025 am 12:11 AM

todropaViewInmysql, "dropviewifexistsview_name;"및 TomodifyAview를 사용하고 "createOrreplaceViewView_NameAsselect ...". "

MySQL보기 : 어떤 디자인 패턴을 사용할 수 있습니까?MySQL보기 : 어떤 디자인 패턴을 사용할 수 있습니까?May 16, 2025 am 12:10 AM

mysqlViewScaneFeficTicallyINGILIDESIGNPATTORNSLIKEADAPTER, DECIARATOR, FACTORY 및 OBSERVER.1) AdapterPatternAdAptSDataFromDifferentTablesinToAunifiedView.2) Decor

MySQL에서 뷰를 사용하면 어떤 장점이 있습니까?MySQL에서 뷰를 사용하면 어떤 장점이 있습니까?May 16, 2025 am 12:09 AM

viewsinmysqlarebeneficialforsimplifyingcomplexqueries, envancingsecurity, dataconsistency, andoptimizing promperformance

MySQL에서 간단한보기를 어떻게 만들 수 있습니까?MySQL에서 간단한보기를 어떻게 만들 수 있습니까?May 16, 2025 am 12:08 AM

toeteimpleviewinmysql, usethecreateviewstatement.1) definetheviewwithReateViewview_nameas.2) specifyTesLectStatementToreTrievesiredData.3) usetheViewLikeAtableForqueries.ViewsSimplifyDataAccessAndenHances, ButconSiderFormance

MySQL 사용자 명령문 생성 : 예제 및 공통 오류MySQL 사용자 명령문 생성 : 예제 및 공통 오류May 16, 2025 am 12:04 AM

toCreateUserSinmysql, usethecreateuserstatement.1) foralocaluser : createUser'LocalUser '@'localHost'IndifiedBy'SecurePassword '; 2) foremoteUser : createUser'RemoteUser'@'%'reidentifiedBy'StrongPassword ';

MySQL에서 뷰를 사용하는 한계는 무엇입니까?MySQL에서 뷰를 사용하는 한계는 무엇입니까?May 14, 2025 am 12:10 AM

mysqlviewshavelimitations : 1) 그들은 upportallsqloperations, datamanipulation throughviewswithjoinsorbqueries를 제한하지 않습니다

MySQL 데이터베이스 확보 : 사용자 추가 및 권한 부여MySQL 데이터베이스 확보 : 사용자 추가 및 권한 부여May 14, 2025 am 12:09 AM

적절한 usermanagementInmysqliscrucialforenhancingsecurityandensuringfefficientDatabaseOperation.1) USECREATEUSERTOWDDUSERS,@'localHost'or@'%'.

MySQL에서 사용할 수있는 트리거 수에 영향을 미치는 요인은 무엇입니까?MySQL에서 사용할 수있는 트리거 수에 영향을 미치는 요인은 무엇입니까?May 14, 2025 am 12:08 AM

mysqldoes notimposeahardlimitontriggers, butpracticalfactorsdeteirefectiveuse : 1) ServerConfigurationimpactStriggerManagement; 2) 복잡한 트리거 스케일 스케일 사이드로드; 3) argertableSlowtriggerTriggerPerformance; 4) High ConconcercencyCancaUspriggerContention; 5) m

See all articles

핫 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 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

Nordhold : Fusion System, 설명
1 몇 달 전By尊渡假赌尊渡假赌尊渡假赌
<exp exp> 모호한 : 원정 33- 완벽한 크로마 촉매를 얻는 방법
2 몇 주 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

안전한 시험 브라우저

안전한 시험 브라우저

안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

메모장++7.3.1

메모장++7.3.1

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

맨티스BT

맨티스BT

Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.