結果
問題 | No.493 とても長い数列と文字列(Long Long Sequence and a String) |
ユーザー |
![]() |
提出日時 | 2017-03-08 17:14:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,122 bytes |
コンパイル時間 | 665 ms |
コンパイル使用メモリ | 69,572 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 19:28:55 |
合計ジャッジ時間 | 3,374 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | AC * 1 WA * 114 |
ソースコード
#include <string>#include <vector>#include <iostream>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--;ll s = (1 << K) - 1; s += s >> 9;if (R > s) cout << -1 << endl;else {vector<ll> r1 = solve(R), r2 = solve(L);int sum = 0, prod = 1;for (int i = 0; i < 10; i++) {sum = (sum + 1LL * z[i] * (r1[i] - r2[i])) % mod;prod = 1LL * prod * modpow(z[i], r1[i] - r2[i]) % mod;}cout << sum << ' ' << prod << endl;}return 0;}