結果

問題 No.2781 A%B問題
コンテスト
ユーザー Arleen
提出日時 2024-06-14 21:34:07
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 590 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 211 ms
コンパイル使用メモリ 85,400 KB
実行使用メモリ 55,328 KB
最終ジャッジ日時 2026-03-06 01:19:13
合計ジャッジ時間 1,776 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# 2個の整数A, Bが与えられる(B != 0)
# AをBで割った余りを求めよ
#
# -100 <= A, B <= 100
# B != 0

import sys
import itertools
import time
from math import radians, sin, cos, tan, sqrt
from collections import deque

def input():
    return sys.stdin.readline().replace('\n','')
sys.setrecursionlimit(1000000)
md1 = 998244353
md2 = 10 ** 9 + 7

A, B = map(int, input().split())

r = A % B

if r < 0:
    while not (0 <= r and r < abs(B)):
        r += abs(B)
else:
    if 0 <= r and abs(B) <= r:
        while not(0 <= r and r < abs(B)):
            r -= abs(B)

print(r)
0