일요일 9시에 열리는 대회는 내가 일정이 있어서 풀 시간이 얼마 없다..ㅠ
그래도 괜찮은(?) 결과가 나와서 기분은 좋았지만 rating은...다.
개인적으로 B번을 시간 안에 못 풀기도 했고, C번은 내가 좋아하는 조합이론 문제가 나와서 대회가 마음에 들었다.
(참고로 내가 가장 좋아하는 문제의 종류는 조합/기하 관련 문제들이다)(물론 쉬운거)
바로 풀이로 들어가자.
A. ABC Preparation
Problem statement
Takahashi has decided to hold some number of programming contests.
Holding one contest requires one 100-point problem, one 200-point problem, one 300-point problem, and one 400-point problem.
When he has , , and drafts of -, -, -, and -point problems, respectively, at most how many contests can he hold?
The same draft can be used only once.
Input
Input is given from Standard Input in the following format:
A1 A2 A3 A4
Output
Print an integer representing the maximum number of contests that can be held.
풀이
어짜피 모든 배점의 문제를 다 똑같은 개수만큼 출제하는 것이기 때문에 가장 적은 개수가 있는 문제의 개수만큼만 대회를 만들 수 있다. 따라서 입력되는 값 중에서 가장 작은 값을 출력하면 된다.
#include<stdio.h>
int min(int a, int b){if(a>=b){return b;}else{return a;}}
int main()
{
int a,b,c,d,;
scanf("%d %d %d %d",&a,&b,&c,&d);
printf("%d",min(a,min(b,min(c,d))));
return 0;
}
[02:29 Accepted]
C. Duodecim Ferra
Problem statement
There is an iron bar of length lying east-west. We will cut this bar at positions to divide it into bars. Here, each of the resulting bars must have a positive integer length.
Find the number of ways to do this division. Two ways to do the division are considered different if and only if there is a position cut in only one of those ways.
Under the constraints of this problem, it can be proved that the answer is less than .
Input
Input is given from Standard Input in the following format:
L
Output
Print the number of ways to do the division.
풀이
길이가 L인 bar에는 자를 수 있는 곳이 L-1개 있다. 그 L-1개 중에서 11개를 선택하는 방법의 수가 정답이므로 L-1C11을 출력하면 된다.
import math
def nCr(n,r):
f = math.factorial
return f(n) // f(r) // f(n-r)
a = int(input())
print(nCr(a-1,11))
다름이 아니라 C로 짜니까 nCr함수에서 오류가 나는지 자꾸 WA 떠서 파이썬으로 풀었다
[67:12 Wrong Answer]
[67:26 Wrong Answer]
[73:55 Runtime Error]
[76:21 Accepted]
B는 업솔빙 예정
'대회 후기 > Atcoder' 카테고리의 다른 글
AtCoder Beginner Contest 189 후기 (0) | 2021.01.24 |
---|---|
Atcoder Beginner Contest 186 (1) | 2020.12.26 |
ABC 184 후기 (0) | 2020.11.23 |