[HackerRank][Python3] Construct the Array
2018. 5. 30. 02:58 |
프로그래밍/HackerRank
Problem :
https://www.hackerrank.com/challenges/construct-the-array/problem
My Solution :
#!/usr/bin/env python3 def countArray(n, k, x): a, b = 1, 0 m = 10**9 + 7 for _ in range(2, n+1): a, b = (k-1)*b % m, ((k-2)*b + a) % m return a if x ==1 else b n, k, x = map(int, input().strip().split()) answer = countArray(n, k, x) print(answer)
'프로그래밍 > HackerRank' 카테고리의 다른 글
[HackerRank][Python3] Minimum Loss (0) | 2018.06.05 |
---|---|
[HackerRank][Python3] Strong Password (0) | 2018.06.05 |
[HackerRank][Python3] Climbing the Leaderboard (0) | 2018.06.01 |
[HackerRank][Python3] The Power Sum (1) | 2018.05.31 |
[HackerRank][Python3] Minimum Absolute Difference in an Array (0) | 2018.05.29 |
[HackerRank][Python3] Big Sorting (0) | 2018.05.29 |
[HackerRank][Python3] CamelCase (0) | 2018.05.27 |
[HackerRank][Python3] Journey to the Moon (0) | 2018.05.25 |
최근에 달린 댓글 최근에 달린 댓글