-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from uta8a/add-wip-example
Add some AtCoder ABC-B examples to `examples/wip`
- Loading branch information
Showing
6 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# https://atcoder.jp/contests/abc200/tasks/abc200_b | ||
|
||
from typing import * | ||
|
||
def solve(n: int, k: int) -> int: | ||
for _ in range(k): | ||
if n % 200 == 0: | ||
n //= 200 | ||
else: | ||
n = n*1000 + 200 | ||
return n | ||
|
||
def main() -> None: | ||
n, k = map(int, input().split()) | ||
ans = solve(n, k) | ||
print(ans) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# https://atcoder.jp/contests/abc203/tasks/abc203_b | ||
|
||
from typing import * | ||
|
||
def solve(n: int, k: int) -> int: | ||
a = [] | ||
for i in range(1,n+1): | ||
for j in range(1,k+1): | ||
a.append(100*i + j) | ||
ans = sum(a) | ||
return ans | ||
|
||
def main() -> None: | ||
n, k = map(int, input().split()) | ||
ans = solve(n, k) | ||
print(ans) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# https://atcoder.jp/contests/abc204/tasks/abc204_b | ||
|
||
from typing import * | ||
|
||
def solve(n: int, a: List[int]) -> int: | ||
ans = 0 | ||
for e in a: | ||
if e > 10: | ||
ans += e - 10 | ||
return ans | ||
|
||
def main() -> None: | ||
n = int(input()) | ||
a = list(map(int, input().split())) | ||
assert len(a) == n | ||
ans = solve(n, a) | ||
print(ans) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# https://atcoder.jp/contests/abc206/tasks/abc206_b | ||
|
||
from typing import * | ||
|
||
def solve(n: int) -> int: | ||
c = 0 | ||
ans = 0 | ||
flag = True | ||
for i in range(100000): # (10^5)^2 > 10^9 | ||
c += i | ||
if c >= n and flag: | ||
ans = i | ||
flag = False | ||
return ans | ||
|
||
def main() -> None: | ||
n = int(input()) | ||
ans = solve(n) | ||
print(ans) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# https://atcoder.jp/contests/abc207/tasks/abc207_b | ||
|
||
from typing import * | ||
|
||
def solve(a: int, b: int, c: int, d: int) -> int: | ||
ans = -1 | ||
if d*c - b > 0: | ||
ans = (a + d*c - b - 1) // (d*c - b) # ans = a /^ (d*c - b) | ||
return ans | ||
|
||
def main() -> None: | ||
a, b, c, d = map(int, input().split()) | ||
ans = solve(a, b, c, d) | ||
print(ans) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# https://atcoder.jp/contests/abc208/tasks/abc208_b | ||
|
||
from typing import * | ||
|
||
def solve(p: int) -> int: | ||
e = 1 | ||
cs = [] | ||
ans = 0 | ||
for i in range(10): | ||
e *= i+1 | ||
cs.append(e) | ||
for c in reversed(cs): | ||
ans += p//c | ||
p -= p//c * c | ||
return ans | ||
|
||
def main() -> None: | ||
p = int(input()) | ||
ans = solve(p) | ||
print(ans) | ||
|
||
if __name__ == '__main__': | ||
main() |