結果
問題 | No.915 Plus Or Multiple Operation |
ユーザー |
|
提出日時 | 2020-04-10 20:09:48 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 655 bytes |
コンパイル時間 | 81 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-11-07 03:46:34 |
合計ジャッジ時間 | 1,167 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
MOD = 10 ** 9 + 7 INF = 10 ** 10 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from collections import deque from heapq import heapify,heappush,heappop def dfs(x,c): if x == 0: return 0 if 0 < x < c: return 1 if c <= x < 2 * c - 1: return 2 if x%c == 0: return dfs(x//c,c) + 1 else: return dfs(x - x%c,c) + 1 def main(): q = int(input()) for _ in range(q): a,b,c = map(int,input().split()) if c == 1: print(-1) continue ans = dfs(a,c) print(ans * b) if __name__ =='__main__': main()