結果
問題 | No.2455 Numbers Dictionary |
ユーザー | mymelochan |
提出日時 | 2023-09-03 04:30:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 263 ms / 2,000 ms |
コード長 | 1,444 bytes |
コンパイル時間 | 700 ms |
コンパイル使用メモリ | 87,336 KB |
実行使用メモリ | 79,496 KB |
最終ジャッジ日時 | 2023-09-03 04:30:39 |
合計ジャッジ時間 | 7,394 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 96 ms
71,788 KB |
testcase_01 | AC | 98 ms
71,644 KB |
testcase_02 | AC | 260 ms
78,716 KB |
testcase_03 | AC | 227 ms
78,532 KB |
testcase_04 | AC | 227 ms
78,812 KB |
testcase_05 | AC | 238 ms
78,388 KB |
testcase_06 | AC | 237 ms
78,696 KB |
testcase_07 | AC | 237 ms
78,684 KB |
testcase_08 | AC | 206 ms
78,780 KB |
testcase_09 | AC | 239 ms
78,532 KB |
testcase_10 | AC | 234 ms
78,440 KB |
testcase_11 | AC | 263 ms
78,616 KB |
testcase_12 | AC | 220 ms
78,564 KB |
testcase_13 | AC | 237 ms
78,436 KB |
testcase_14 | AC | 230 ms
78,480 KB |
testcase_15 | AC | 236 ms
78,680 KB |
testcase_16 | AC | 234 ms
78,676 KB |
testcase_17 | AC | 232 ms
78,472 KB |
testcase_18 | AC | 186 ms
79,140 KB |
testcase_19 | AC | 196 ms
79,496 KB |
testcase_20 | AC | 248 ms
78,520 KB |
testcase_21 | AC | 255 ms
78,496 KB |
testcase_22 | AC | 235 ms
78,336 KB |
ソースコード
############################################################# import sys sys.setrecursionlimit(10**7) from heapq import heappop,heappush from collections import deque,defaultdict,Counter from bisect import bisect_left, bisect_right from itertools import product,combinations,permutations ipt = sys.stdin.readline def iin(): return int(ipt()) def lmin(): return list(map(int,ipt().split())) MOD = 998244353 ############################################################# def solve(N,K): L = len(N) cnt = 0 for i in range(1,L): for j in range(i): if j >= len(K): break cnt += (int(K[j])-(j==0))*10**(i-j-1) #print(j,cnt,int(K[j])-(j==0)) if i < len(K): cnt += 1 #print("a") #print(cnt) f = 0 for j in range(L): if j >= len(K): break if f == 0: if int(N[j]) > int(K[j]): cnt += (int(K[j])-(j==0))*10**(L-j-1) f = 1 elif int(N[j]) < int(K[j]): cnt += (int(N[j])-(j==0))*10**(L-j-1) #f = 2 cnt += int(N)-int(N[:j+1])*10**(L-j-1)+1 break else: cnt += (int(K[j])-(j==0))*10**(L-j-1) elif f == 1: cnt += int(K[j])*10**(L-j-1) cnt += 1 return cnt for _ in range(iin()): N,K = input().split() print(solve(N,K))