結果

問題 No.493 とても長い数列と文字列(Long Long Sequence and a String)
ユーザー char134217728char134217728
提出日時 2017-12-30 01:16:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,447 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 205,116 KB
実行使用メモリ 7,800 KB
最終ジャッジ日時 2023-08-23 09:27:55
合計ジャッジ時間 7,601 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:76:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   76 | main(){
      | ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) a.begin(),a.end()
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
ll a[61][3];
string st[61];
pair<int, pll> parse(ll n){
  ll s=0, p=1;
  int l = 0, c, nn = n * n;
  stringstream ss;
  ss << nn;
  st[n] = ss.str();
  while(nn > 0){
    l++;
    c = nn % 10;
    s += c;
    p *= (c == 0 ? 10 : c);
    nn /= 10;
  }
  return mp(l, mp(s, p));
}
pll search(int n, ll l, ll r){
  if(n == 0 || l >= r) return mp(0, 1);
  pll t;
  ll s = 0, p = 1, d;
  t = search(n-1, l, min(r, a[n-1][0]));
  s = (s + t.fi)%mod;
  p = p * t.se % mod;
  FOR(i, max(0ll, min(l-a[n-1][0], ll(sz(st[n])))), min(ll(sz(st[n])), r-a[n-1][0])){
    d = st[n][i] - '0';
    s += d;
    p *= (d == 0 ? 10 : d);
  }
  s %= mod;
  p %= mod;
  d = a[n-1][0] + sz(st[n]);
  t = search(n-1, max(l-d, 0ll), r-d);
  s = (s + t.fi)%mod;
  p = p * t.se % mod;
  return mp(s, p);
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  a[0][2] = 1;
  pair<int, pll> t;
  FOR(i, 1, 61){
    t = parse(i);
    a[i][0] = (a[i-1][0] * 2 + t.fi);
    a[i][1] = (a[i-1][1] * 2 + t.se.fi)%mod;
    a[i][2] = a[i-1][2] * a[i-1][2] % mod * t.se.se % mod;
  }
  int K;
  ll L, R;
  cin >> K >> L >> R;
  if(a[K][0] < R){
    cout << -1 << endl;
    return 0;
  }
  pll ans = search(K, L-1, R);
  cout << ans.fi << " " << ans.se << endl;
  return 0;
}
0