結果

問題 No.493 とても長い数列と文字列(Long Long Sequence and a String)
ユーザー chocoruskchocorusk
提出日時 2020-04-08 18:09:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,936 bytes
コンパイル時間 931 ms
コンパイル使用メモリ 109,324 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-26 05:31:23
合計ジャッジ時間 5,480 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 WA -
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 WA -
testcase_50 AC 1 ms
4,376 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 AC 2 ms
4,380 KB
testcase_53 WA -
testcase_54 AC 2 ms
4,380 KB
testcase_55 AC 2 ms
4,376 KB
testcase_56 AC 2 ms
4,376 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 WA -
testcase_59 AC 2 ms
4,376 KB
testcase_60 WA -
testcase_61 AC 2 ms
4,380 KB
testcase_62 WA -
testcase_63 AC 1 ms
4,376 KB
testcase_64 AC 1 ms
4,380 KB
testcase_65 AC 2 ms
4,380 KB
testcase_66 AC 2 ms
4,376 KB
testcase_67 AC 1 ms
4,380 KB
testcase_68 AC 2 ms
4,376 KB
testcase_69 AC 1 ms
4,376 KB
testcase_70 AC 1 ms
4,380 KB
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 AC 2 ms
4,380 KB
testcase_75 AC 2 ms
4,376 KB
testcase_76 WA -
testcase_77 AC 1 ms
4,376 KB
testcase_78 AC 1 ms
4,380 KB
testcase_79 WA -
testcase_80 AC 1 ms
4,376 KB
testcase_81 WA -
testcase_82 AC 2 ms
4,376 KB
testcase_83 AC 1 ms
4,376 KB
testcase_84 AC 1 ms
4,380 KB
testcase_85 WA -
testcase_86 WA -
testcase_87 AC 2 ms
4,380 KB
testcase_88 AC 2 ms
4,376 KB
testcase_89 AC 1 ms
4,376 KB
testcase_90 AC 1 ms
4,376 KB
testcase_91 WA -
testcase_92 AC 2 ms
4,380 KB
testcase_93 AC 1 ms
4,380 KB
testcase_94 AC 2 ms
4,376 KB
testcase_95 AC 2 ms
4,376 KB
testcase_96 AC 1 ms
4,380 KB
testcase_97 WA -
testcase_98 AC 2 ms
4,376 KB
testcase_99 AC 1 ms
4,380 KB
testcase_100 AC 1 ms
4,376 KB
testcase_101 WA -
testcase_102 WA -
testcase_103 AC 1 ms
4,376 KB
testcase_104 AC 1 ms
4,376 KB
testcase_105 AC 1 ms
4,380 KB
testcase_106 AC 1 ms
4,376 KB
testcase_107 AC 2 ms
4,380 KB
testcase_108 AC 2 ms
4,376 KB
testcase_109 AC 1 ms
4,376 KB
testcase_110 AC 1 ms
4,376 KB
testcase_111 AC 2 ms
4,376 KB
testcase_112 AC 2 ms
4,380 KB
testcase_113 AC 1 ms
4,376 KB
testcase_114 WA -
testcase_115 AC 2 ms
4,380 KB
testcase_116 AC 2 ms
4,376 KB
testcase_117 AC 2 ms
4,380 KB
testcase_118 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
//typedef long long int ll;
//typedef pair<int, int> P;
using ll=unsigned long long;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll a[61], s[61], p[61];
ll solves(int k, ll r){
	if(r==0) return 0;
	if(k==1) return 1;
	if(r<=a[k-1]) return solves(k-1, r);
	int d[4], t=0, x=k*k;
	ll ret=s[k-1];
	while(x){
		d[t]=x%10;
		x/=10;
		if(r-a[k-1]>t) ret+=((d[t]==0)?10:d[t]);
		t++;
	}
	if(r<=a[k-1]+t) return ret;
	else return ret+solves(k-1, r-t-a[k-1]);
}
ll solvep(int k, ll r){
	if(r==0 || k==1) return 1;
	if(r<=a[k-1]) return solvep(k-1, r);
	int d[4], t=0, x=k*k;
	ll ret=p[k-1];
	while(x){
		d[t]=x%10;
		x/=10;
		if(r-a[k-1]>t) (ret*=((d[t]==0)?10:d[t]))%=MOD;
		t++;
	}
	if(r<=a[k-1]+t) return ret;
	else return ret*solvep(k-1, r-t-a[k-1])%MOD;
}
int main()
{
	ll k, l, r;
	cin>>k>>l>>r;
	k=min(k, 60ull);
	a[1]=1, s[1]=1, p[1]=1;
	for(int i=2; i<=60; i++){
		int x=i*i;
		a[i]=2*a[i-1];
		s[i]=2*s[i-1];
		p[i]=p[i-1]*p[i-1]%MOD;
		int d[4], t=0;
		while(x){
			d[t]=x%10;
			x/=10;
			s[i]+=((d[t]==0)?10:d[t]);
			(p[i]*=((d[t]==0)?10:d[t]))%=MOD;
			t++;
		}
		a[i]+=t;
	}
	if(a[k]<r){
		cout<<-1<<endl;
		return 0;
	}
	cout<<solves(k, r)-solves(k, l-1)<<" "<<solvep(k, r)*inv(solvep(k, l-1))%MOD<<endl;
	return 0;
}
0