結果
問題 | No.528 10^9と10^9+7と回文 |
ユーザー | vwxyz |
提出日時 | 2023-02-16 01:52:17 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 395 ms / 1,000 ms |
コード長 | 1,354 bytes |
コンパイル時間 | 188 ms |
コンパイル使用メモリ | 11,044 KB |
実行使用メモリ | 12,976 KB |
最終ジャッジ日時 | 2023-09-25 08:57:50 |
合計ジャッジ時間 | 6,601 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
10,484 KB |
testcase_01 | AC | 34 ms
10,412 KB |
testcase_02 | AC | 34 ms
10,436 KB |
testcase_03 | AC | 34 ms
10,544 KB |
testcase_04 | AC | 34 ms
10,404 KB |
testcase_05 | AC | 33 ms
10,308 KB |
testcase_06 | AC | 34 ms
10,480 KB |
testcase_07 | AC | 34 ms
10,312 KB |
testcase_08 | AC | 35 ms
10,324 KB |
testcase_09 | AC | 34 ms
10,408 KB |
testcase_10 | AC | 362 ms
12,976 KB |
testcase_11 | AC | 351 ms
12,828 KB |
testcase_12 | AC | 352 ms
12,932 KB |
testcase_13 | AC | 354 ms
12,808 KB |
testcase_14 | AC | 233 ms
11,700 KB |
testcase_15 | AC | 209 ms
11,764 KB |
testcase_16 | AC | 194 ms
11,756 KB |
testcase_17 | AC | 168 ms
11,472 KB |
testcase_18 | AC | 364 ms
12,972 KB |
testcase_19 | AC | 122 ms
11,176 KB |
testcase_20 | AC | 273 ms
12,028 KB |
testcase_21 | AC | 155 ms
11,320 KB |
testcase_22 | AC | 34 ms
10,308 KB |
testcase_23 | AC | 34 ms
10,480 KB |
testcase_24 | AC | 37 ms
10,440 KB |
testcase_25 | AC | 64 ms
10,640 KB |
testcase_26 | AC | 358 ms
12,872 KB |
testcase_27 | AC | 395 ms
12,908 KB |
ソースコード
import bisect import copy import decimal import fractions import heapq import itertools import math import random import sys import time from collections import Counter,deque,defaultdict from functools import lru_cache,reduce from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max def _heappush_max(heap,item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappushpop_max(heap, item): if heap and item < heap[0]: item, heap[0] = heap[0], item heapq._siftup_max(heap, 0) return item from math import gcd as GCD read=sys.stdin.read readline=sys.stdin.readline readlines=sys.stdin.readlines write=sys.stdout.write N=list(map(int,list(readline().rstrip()))) le=len(N) for mod in (10**9,10**9+7): ans=0 for i in range(1,le): ans+=9*pow(10,(i-1)//2,mod) ans%=mod if le>=2: dp=0 for n in N[:le//2]: dp*=10 dp+=n dp%=mod dp-=pow(10,le//2-1,mod) if le%2: dp*=10 dp%=mod ans+=dp ans%=mod if le%2: for i in range(1 if le==1 else 0,10): if N[:le//2]+[i]+N[:le//2][::-1]<=N: ans+=1 ans%=mod else: if N[:le//2]+N[:le//2][::-1]<=N: ans+=1 ans%=mod print(ans)