https://atcoder.jp/contests/abc156 A
n,r = map(int, input().split())
ans = r
if n < 10: ans = r + 100 * (10 - n)
print(ans)
Recalculate the internal rate only if n is less than 10.
Submission https://atcoder.jp/contests/abc156/submissions/10269586
B
n,k = map(int, input().split())
def base(a, b):
if (int(a/b)): return base(int(a/b), b) + str(a % b)
return str(a % b)
ans = base(n, k)
print(len(ans))
To convert the decimal digit ʻato a
b` base
-** divide a by b **
-** Arrange the remainder from the first digit **
There is a method of repeating these two ** until the quotient of ** a ÷ b becomes 0 (stops when it becomes 0).
(During the contest, I checked the calculation method and imitated it.)
Submission https://atcoder.jp/contests/abc156/submissions/10274589
C
n = int(input())
*x, = map(int, input().split())
ans = float('inf')
for i in range(min(x), max(x)+1):
tmp = 0
for j in x:
tmp += (j - i)*(j - i)
ans = min(ans, tmp)
print(ans)
~~ Sort the coordinates of the inhabitants in ascending order, ~~
In the range from the minimum to the maximum, when each coordinate is used as the place to hold the rally (ʻi for statement), The total physical strength consumed by each resident was calculated (
j`for statement) and the minimum value was considered.
Since N is small, it's okay to check everything (I noticed on the way).
Submission https://atcoder.jp/contests/abc156/submissions/10326967
~~https://atcoder.jp/contests/abc156/submissions/10281863~~
** Additions / corrections ** We received comments from @ c-yan and corrected the unnecessary sort parts.
I would like to add it if I can AC.
Recommended Posts