結果
問題 | No.493 とても長い数列と文字列(Long Long Sequence and a String) |
ユーザー |
![]() |
提出日時 | 2017-03-08 17:46:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,163 bytes |
コンパイル時間 | 654 ms |
コンパイル使用メモリ | 73,232 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 19:30:19 |
合計ジャッジ時間 | 3,164 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | AC * 2 WA * 113 |
ソースコード
#include <string>#include <vector>#include <iostream>#include <algorithm>using namespace std;const int mod = 1000000007;typedef long long ll;vector<ll> solve(ll x) {ll l = 0, r = 1LL << 60;while (r - l > 1) {ll m = (l + r) >> 1;if (m + (m >> 9) <= x) l = m;else r = m;}vector<ll> v(10);for (int i = 0; i < 60; i++) {ll c = (l >> i) - (l >> (i + 1));int b = i + 1;while (b > 0) {v[b % 10] += c;b /= 10;}}if (l + (l >> 9) != x) {int c = 1; l++;while (!(l & 1)) l >>= 1, c++;v[c / 10]++;}return v;}int modpow(int a, ll b) {ll ret = 1;while (b) {if (b & 1) ret = 1LL * ret * a % mod;a = 1LL * a * a % mod;b >>= 1;}return ret;}int z[] = { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9 };ll K, L, R;int main() {cin >> K >> L >> R; L--; K = min(K, 61LL);ll s = (1LL << K) - 1; s += s >> 9;if (R > s) cout << -1 << endl;else {vector<ll> r1 = solve(R), r2 = solve(L);long long sum = 0; int prod = 1;for (int i = 0; i < 10; i++) {sum += 1LL * z[i] * (r1[i] - r2[i]);prod = 1LL * prod * modpow(z[i], r1[i] - r2[i]) % mod;}cout << sum << ' ' << prod << endl;}return 0;}