반응형

문제 링크: https://www.acmicpc.net/problem/12727

 

12727번: Numbers (Small)

The first line of input gives the number of cases, T. T test cases follow, each on a separate line. Each test case contains one positive integer n. Limits 1 <= T <= 100 2 <= n <= 30

www.acmicpc.net

<문제 풀이> 수학

https://www.acmicpc.net/problem/12728

 

12728번: n제곱 계산

이 문제에서 숫자 (3 + √5)n 에 대한 소수점 앞에 마지막 세 자리를 찾아야합니다. 예를 들어, n = 5 일 때 (3 + √5)5  = 3935.73982 ... 이므로 답은 935입니다. n = 2 인 경우 (3 + √5)2 = 27.4164079 … 이므로, 답은 027입니다.

www.acmicpc.net

백준 12728번의 n제한이 작은 버전

12728번 풀이를 참조해서 점화식을 구하면 됨 

이 문제는 점화식 dp로 O(n)에 해결 가능하다.

반응형

+ Recent posts