Created
July 13, 2021 07:13
-
-
Save uchidama/c4e3d5db78c980de4b02ce804ef77010 to your computer and use it in GitHub Desktop.
AtCoder Beginner Contest 162 [ B - FizzBuzz Sum ] https://atcoder.jp/contests/abc162/tasks/abc162_b
This file contains hidden or 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
''' | |
[問題] | |
https://atcoder.jp/contests/abc162/tasks/abc162_b | |
[解説] | |
https://atcoder.jp/contests/abc162/editorial/2275 | |
for分の繰り返し範囲指定の、うっかりミスに注意。 | |
N未満まで回すのか、N以下まで回すのか | |
''' | |
import sys | |
sys.setrecursionlimit(10 ** 6) # 再帰上限の引き上げ | |
input = sys.stdin.readline | |
INF = 2 ** 63 - 1 | |
N = int(input()) | |
ans = 0 | |
# rangeの値に注意。N+1でないと、例えばN=15のときに15まで回らない。 | |
for i in range(1, N+1): | |
if i%3 == 0: | |
continue | |
if i%5 == 0: | |
continue | |
ans += i | |
print(ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment