結果
| 問題 | No.3022 一元一次式 mod 1000000000 |
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-05-14 13:11:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,513 bytes |
| コンパイル時間 | 278 ms |
| コンパイル使用メモリ | 82,276 KB |
| 実行使用メモリ | 76,536 KB |
| 最終ジャッジ日時 | 2025-05-14 13:13:30 |
| 合計ジャッジ時間 | 2,070 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 20 |
ソースコード
import sys
# Function to read a single line of input
def input():
return sys.stdin.readline().strip()
# Read the integer N
# Note: input() reads a string, int() converts it.
# The input string itself might contain digits, but that's allowed.
# The restriction is on the source code file.
n_str = input()
N = int(n_str)
# --- Define constants without using digit characters ---
# Use len() of strings to get small integers
_s_abc = "abc" # Length is 3
three = len(_s_abc)
_s_abcde = "abcde" # Length is 5
five = len(_s_abcde)
# Calculate other needed numbers using the defined constants
# Using integer division or subtraction to get 1 and 0
one = three // three # 3 // 3 = 1
zero = three - three # 3 - 3 = 0
# Calculate 15
fifteen = three * five # 3 * 5 = 15
# --- FizzBuzz Logic ---
# Initialize the counter
i = one # Start from 1
# Loop from 1 up to N (inclusive)
while i <= N:
# Check for divisibility using the modulo operator (%) and compare with zero
# Order matters: check for 15 first, then 3, then 5.
is_divisible_by_fifteen = (i % fifteen == zero)
is_divisible_by_three = (i % three == zero)
is_divisible_by_five = (i % five == zero)
if is_divisible_by_fifteen:
print("FizzBuzz")
elif is_divisible_by_three:
print("Fizz")
elif is_divisible_by_five:
print("Buzz")
else:
# Print the number itself if none of the above conditions are met
print(i)
# Increment the counter
i = i + one # i = i + 1
qwewe