結果
| 問題 | 
                            No.2781 A%B問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-06-14 21:34:07 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 42 ms / 2,000 ms | 
| コード長 | 590 bytes | 
| コンパイル時間 | 427 ms | 
| コンパイル使用メモリ | 81,920 KB | 
| 実行使用メモリ | 53,760 KB | 
| 最終ジャッジ日時 | 2024-06-14 21:34:10 | 
| 合計ジャッジ時間 | 1,906 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 | 
ソースコード
# 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)