본문 바로가기

728x90

알고리즘 노트/AtCoder

(8)
AtCoder: E - Double Factorial - 파이썬(Python) https://atcoder.jp/contests/abc148/tasks/abc148_e E - Double FactorialAtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.atcoder.jp 선지>정수 n이 0보다 작지 않은 경우, $f(n)$을 다음과 같이 정의한다. $f(n)=1 \; (n$f(n)=nf(n−2) \; (n≥2)$정수 $N$이 주어졌을 때, $f(N)$의 10진수 표기법에서 끝에 붙는 0의 개수를 구하라. $f(N)$에서 끝의 자리 0의 개수를 구하는 문제이다. 즉, 인수분해를 할 때, 10을 몇번 곱했는지 구하는 문제로..
AtCoder: D - Integer Cards - 파이썬(Python) https://atcoder.jp/contests/abc127/tasks/abc127_d D - Integer CardsAtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.atcoder.jp 선지>$N$장의 카드가 있다. $i$번째 카드에 정수 $A_i$가 쓰여 있다.이 순서로 $j=1,2,...,M$마다 다음 연산을 한 번 수행한다.연산: 최대 $B_j$장의 카드를 선택한다(0장 이상). 선택한 각 카드에 쓰여진 정수를 $C_j$로 변경한다.$M$ 연산 후, $N$장의 카드에 쓰여진 정수의 최대 합을 구하라.$N$개의 정수 중에서 $M$번의 "..
AtCoder: C - Dubious Document 2 - 파이썬(Python) https://atcoder.jp/contests/abc076/tasks/abc076_c C - Dubious Document 2AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.atcoder.jpE869120은 보물이 들어 있을 가능성이 있는 상자를 찾았다.하지만 상자는 잠겨 있다. 상자를 열려면 소문자 영어 문자로 구성된 문자열 $S$를 입력해야 한다.그는 또한 문자열 $S'$ 를 찾았는데, 이는 문자열 $S$의 일부 문자(전부 또는 전혀 없음 가능)가 ?로 변경되었다.그가 찾은 또 다른 것은 다음 사실이 적힌 종이 한 장이다.조건 1: 문..
AtCoder: D - Powerful Discount Tickets - 파이썬(Python) https://atcoder.jp/contests/abc141/tasks/abc141_d D - Powerful Discount TicketsAtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.atcoder.jp 다카하시는 $N$개의 품목을 하나씩 사려고 한다.그가 사는 $i$번째 품목의 가격은 $A_i$ ​ 엔(일본의 통화)이다.그는 $M$개의 할인 티켓을 가지고 있으며, 품목을 살 때 원하는 만큼 사용할 수 있습니다.만약 $Y$개의 티켓을 사용하여 가격이 $X$엔인 품목을 살 경우, 그는 품목을 $\frac{X}{2^Y}​$ 엔(가장 가까운 ..
AtCoder: B - Between a and b ... - 파이썬(Python) https://atcoder.jp/contests/abc048/tasks/abc048_b B - Between a and b ...AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.atcoder.jp음이 아닌 정수 a와 b(a≤b)와 양의 정수 x가 있다고 하자. a와 b 사이의 정수 중에서 x로 나누어 떨어지는 정수는 몇 개인가? a와 b 사이의 x의 배수의 개수를 찾는 문제이다. 단순히 for문을 이용하면 TLE가 발생할 것이다. 왜냐하면 a, b의 최대 범위는 $10^{18}$이 될 수 있고 해당 범위는 제한 시간인 2초 내로 실행할 수 ..
AtCoder: A - Range Flip Find Route - 파이썬(Python) https://atcoder.jp/contests/agc043/tasks/agc043_a A - Range Flip Find RouteAtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.atcoder.jpH개의 행과 W개의 열로 구성된 정사각형이 있는 격자를 생각하자.$(r, c)$는 위에서 r번째 행과 왼쪽에서 c번째 열에 있는 정사각형이다. 각 정사각형은 검은색 또는 흰색으로 되어있다.다음 조건이 충족되는 경우에만 격자가 좋다고 한다.$(1,1)$에서 오른쪽 또는 아래로 한 정사각형을 반복해서 이동하면 $(H,W)$에 도달할 수 있으며, 항상..
AtCoder: B - Kleene Inversion - 파이썬(Python) https://atcoder.jp/contests/jsc2019-qual/tasks/jsc2019_qual_b B - Kleene InversionAtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.atcoder.jp$N$개의 정수 수열 $A = A_0, A_1, ... , A_{N-1}$ 가 있다고 하자.$B$는 $A$의 $K$개의 사본을 연결하여 만든 $K \times N$ 개의 정수로 이루어진 수열이다.예를 들어, $A = 1, 3, 2$이고 $K = 2$이면 $B = 1, 3, 2, 1, 3, 2$이다.$B$의 반전 수에서 $10^9+7$..
AtCoder: D - Gathering Children - 파이썬(Python) https://atcoder.jp/contests/abc136/tasks/abc136_d D - Gathering ChildrenAtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.atcoder.jpN을 S의 길이라고 하자. 왼쪽에서 오른쪽으로 배열된 N개의 사각형이 있고, 왼쪽에서 S의 i번째 문자가 왼쪽에서 i번째 사각형에 쓰여 있다.가장 왼쪽 사각형에 쓰인 문자는 항상 R이고, 가장 오른쪽 사각형에 쓰인 문자는 항상 L이다.처음에는 각 사각형에 한 명의 어린이가 서 있다.각 어린이는 아래의 이동을 10^100회 수행한다.어린이가 서 있는 사..


728x90