結果

問題 No.493 とても長い数列と文字列(Long Long Sequence and a String)
ユーザー titiatitia
提出日時 2023-06-22 01:23:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,511 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 10,820 KB
実行使用メモリ 12,812 KB
最終ジャッジ日時 2023-09-11 20:16:38
合計ジャッジ時間 34,092 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,548 KB
testcase_01 AC 16 ms
7,988 KB
testcase_02 AC 17 ms
8,124 KB
testcase_03 AC 16 ms
8,276 KB
testcase_04 AC 23 ms
8,104 KB
testcase_05 AC 19 ms
8,068 KB
testcase_06 AC 22 ms
8,016 KB
testcase_07 AC 529 ms
8,104 KB
testcase_08 AC 17 ms
8,324 KB
testcase_09 AC 384 ms
8,228 KB
testcase_10 AC 486 ms
8,124 KB
testcase_11 AC 241 ms
8,196 KB
testcase_12 TLE -
testcase_13 AC 487 ms
8,100 KB
testcase_14 TLE -
testcase_15 AC 362 ms
8,132 KB
testcase_16 AC 644 ms
7,988 KB
testcase_17 AC 720 ms
8,068 KB
testcase_18 AC 244 ms
8,232 KB
testcase_19 AC 133 ms
7,988 KB
testcase_20 AC 349 ms
8,012 KB
testcase_21 AC 328 ms
8,044 KB
testcase_22 AC 495 ms
8,096 KB
testcase_23 AC 577 ms
8,072 KB
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 275 ms
8,200 KB
testcase_27 TLE -
testcase_28 AC 691 ms
8,092 KB
testcase_29 TLE -
testcase_30 AC 761 ms
8,048 KB
testcase_31 AC 498 ms
8,028 KB
testcase_32 AC 342 ms
8,140 KB
testcase_33 AC 630 ms
8,216 KB
testcase_34 AC 292 ms
8,068 KB
testcase_35 AC 231 ms
8,168 KB
testcase_36 AC 265 ms
8,132 KB
testcase_37 AC 697 ms
8,128 KB
testcase_38 AC 465 ms
8,128 KB
testcase_39 AC 350 ms
8,168 KB
testcase_40 AC 309 ms
8,048 KB
testcase_41 AC 366 ms
8,124 KB
testcase_42 TLE -
testcase_43 AC 688 ms
8,012 KB
testcase_44 TLE -
testcase_45 AC 129 ms
8,056 KB
testcase_46 AC 448 ms
8,124 KB
testcase_47 AC 731 ms
8,140 KB
testcase_48 AC 653 ms
8,044 KB
testcase_49 AC 249 ms
8,124 KB
testcase_50 AC 604 ms
8,088 KB
testcase_51 AC 98 ms
8,024 KB
testcase_52 AC 250 ms
8,044 KB
testcase_53 AC 473 ms
8,016 KB
testcase_54 TLE -
testcase_55 TLE -
testcase_56 AC 383 ms
8,080 KB
testcase_57 AC 357 ms
8,020 KB
testcase_58 AC 733 ms
8,024 KB
testcase_59 TLE -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
testcase_94 -- -
testcase_95 -- -
testcase_96 -- -
testcase_97 -- -
testcase_98 -- -
testcase_99 -- -
testcase_100 -- -
testcase_101 -- -
testcase_102 -- -
testcase_103 -- -
testcase_104 -- -
testcase_105 -- -
testcase_106 -- -
testcase_107 -- -
testcase_108 -- -
testcase_109 -- -
testcase_110 -- -
testcase_111 -- -
testcase_112 -- -
testcase_113 -- -
testcase_114 -- -
testcase_115 -- -
testcase_116 -- -
testcase_117 -- -
testcase_118 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

K,L,R=map(int,input().split())

mod=10**9+7

K=min(K,64)
K-=1

MOJI=[1]
SUM=[1]
MUL=[1]
for i in range(65):
    k=(i+2)**2
    S=0
    M=1
    for s in str(k):
        if s=="0":
            S+=10
            M*=10
        else:
            S+=int(s)
            M*=int(s)
        M%=mod
    MOJI.append(MOJI[-1]*2+len(str((i+2)**2)))
    SUM.append(SUM[-1]*2+S)
    MUL.append(MUL[-1]*MUL[-1]*M%mod)

if R>MOJI[K]:
    print(-1)
    exit()

if K==0:
    print(0,0)
    exit()

def calc(K,x):
    #print("!",K,x)
    if x==0:
        return 0,1
    if MOJI[K]==x:
        return SUM[K],MUL[K]
    S=0
    M=1

    if MOJI[K-1]==x:
        return SUM[K-1],MUL[K-1]
    if MOJI[K-1]<x:
        nec=str((K+1)**2)

        S=SUM[K-1]
        M=MUL[K-1]

        x-=MOJI[K-1]

        if x<=len(nec):
            for i in range(x):
                if nec[i]=="0":
                    S+=10
                    M*=10
                else:
                    S+=int(nec[i])
                    M*=int(nec[i])

                M%=mod

            return S,M
        else:
            x-=len(nec)
            for i in range(len(nec)):
                if nec[i]=="0":
                    S+=10
                    M*=10
                else:
                    S+=int(nec[i])
                    M*=int(nec[i])

                M%=mod

            return S+calc(K-1,x)[0],M*calc(K-1,x)[1]%mod
    else:
        return calc(K-1,x)[0],M*calc(K-1,x)[1]%mod

a,b=calc(K,L-1)
c,d=calc(K,R)

print(c-a,d*pow(b,mod-2,mod)%mod)
0