結果

問題 No.319 happy b1rthday 2 me
ユーザー vwxyz
提出日時 2023-02-02 16:08:37
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 2,285 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 13,056 KB
実行使用メモリ 12,160 KB
最終ジャッジ日時 2024-07-02 04:35:28
合計ジャッジ時間 2,868 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

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
A,B=map(int,readline().split())
B+=1
def solve(x):
xx=x
X=list(map(int,list(str(x))))
dp=[0]*2
dp_cnt=[0]*2
for i in range(1,X[0]):
if i==1:
dp_cnt[1]+=1
else:
dp_cnt[0]+=1
cnt=0
if X[0]==1:
cur=1
else:
cur=0
for x in X[1:]:
prev=dp
prev_cnt=dp_cnt
dp=[0]*2
dp_cnt=[0]*2
for i in range(10):
if i==1:
dp[1]+=prev[0]+prev[1]
dp_cnt[1]+=prev_cnt[0]+prev_cnt[1]
elif i==2:
dp[0]+=prev[0]+prev[1]+prev_cnt[1]
dp_cnt[0]+=prev_cnt[0]+prev_cnt[1]
else:
dp[0]+=prev[0]+prev[1]
dp_cnt[0]+=prev_cnt[0]+prev_cnt[1]
for i in range(1,10):
if i==1:
dp_cnt[1]+=1
else:
dp_cnt[0]+=1
for i in range(x):
if i==1:
dp[1]+=cnt
dp_cnt[1]+=1
elif i==2:
dp[0]+=cnt
if cur:
dp[0]+=1
dp_cnt[0]+=1
else:
dp[0]+=cnt
dp_cnt[0]+=1
if x==1:
cur=1
elif x==2 and cur:
cnt+=1
cur=0
else:
cur=0
ans=0
x=xx
if x>=23:
x-=3
x//=10
x+=1
le=len(str(x))
for i in range(le-1):
ans+=10**i
ans+=max(0,min(10**(le-1),x-2*10**(le-1)))
return ans+dp[0]+dp[1]
ans=solve(B)-solve(A)
print(ans)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0