結果
問題 | No.493 とても長い数列と文字列(Long Long Sequence and a String) |
ユーザー | e869120 |
提出日時 | 2017-03-08 20:33:39 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,254 bytes |
コンパイル時間 | 683 ms |
コンパイル使用メモリ | 72,484 KB |
実行使用メモリ | 13,760 KB |
最終ジャッジ日時 | 2024-06-23 19:30:33 |
合計ジャッジ時間 | 4,989 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
13,760 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | WA | - |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 2 ms
6,944 KB |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | WA | - |
testcase_21 | AC | 2 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | AC | 2 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 2 ms
6,944 KB |
testcase_26 | AC | 2 ms
6,944 KB |
testcase_27 | AC | 2 ms
6,944 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | AC | 2 ms
6,940 KB |
testcase_30 | AC | 2 ms
6,940 KB |
testcase_31 | AC | 1 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,940 KB |
testcase_33 | AC | 2 ms
6,940 KB |
testcase_34 | AC | 2 ms
6,940 KB |
testcase_35 | AC | 2 ms
6,940 KB |
testcase_36 | AC | 2 ms
6,940 KB |
testcase_37 | AC | 2 ms
6,944 KB |
testcase_38 | AC | 2 ms
6,944 KB |
testcase_39 | WA | - |
testcase_40 | AC | 2 ms
6,940 KB |
testcase_41 | AC | 2 ms
6,940 KB |
testcase_42 | AC | 2 ms
6,940 KB |
testcase_43 | AC | 2 ms
6,944 KB |
testcase_44 | AC | 2 ms
6,944 KB |
testcase_45 | AC | 2 ms
6,944 KB |
testcase_46 | AC | 2 ms
6,944 KB |
testcase_47 | AC | 1 ms
6,940 KB |
testcase_48 | AC | 2 ms
6,944 KB |
testcase_49 | WA | - |
testcase_50 | AC | 2 ms
6,940 KB |
testcase_51 | AC | 2 ms
6,944 KB |
testcase_52 | AC | 2 ms
6,948 KB |
testcase_53 | WA | - |
testcase_54 | AC | 2 ms
6,940 KB |
testcase_55 | AC | 2 ms
6,940 KB |
testcase_56 | AC | 2 ms
6,940 KB |
testcase_57 | AC | 2 ms
6,940 KB |
testcase_58 | WA | - |
testcase_59 | AC | 2 ms
6,944 KB |
testcase_60 | WA | - |
testcase_61 | AC | 2 ms
6,940 KB |
testcase_62 | WA | - |
testcase_63 | AC | 2 ms
6,940 KB |
testcase_64 | AC | 2 ms
6,940 KB |
testcase_65 | AC | 2 ms
6,940 KB |
testcase_66 | AC | 2 ms
6,940 KB |
testcase_67 | AC | 2 ms
6,940 KB |
testcase_68 | AC | 2 ms
6,940 KB |
testcase_69 | AC | 3 ms
6,944 KB |
testcase_70 | AC | 3 ms
6,940 KB |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | AC | 2 ms
6,940 KB |
testcase_75 | AC | 2 ms
6,940 KB |
testcase_76 | WA | - |
testcase_77 | AC | 2 ms
6,944 KB |
testcase_78 | AC | 2 ms
6,940 KB |
testcase_79 | AC | 2 ms
6,940 KB |
testcase_80 | AC | 2 ms
6,944 KB |
testcase_81 | AC | 2 ms
6,940 KB |
testcase_82 | AC | 2 ms
6,940 KB |
testcase_83 | AC | 2 ms
6,940 KB |
testcase_84 | AC | 2 ms
6,944 KB |
testcase_85 | AC | 2 ms
6,944 KB |
testcase_86 | WA | - |
testcase_87 | AC | 2 ms
6,940 KB |
testcase_88 | AC | 2 ms
6,940 KB |
testcase_89 | AC | 2 ms
6,940 KB |
testcase_90 | AC | 3 ms
6,944 KB |
testcase_91 | WA | - |
testcase_92 | AC | 2 ms
6,940 KB |
testcase_93 | AC | 2 ms
6,940 KB |
testcase_94 | AC | 2 ms
6,940 KB |
testcase_95 | AC | 2 ms
6,940 KB |
testcase_96 | AC | 2 ms
6,944 KB |
testcase_97 | AC | 2 ms
6,940 KB |
testcase_98 | AC | 2 ms
6,940 KB |
testcase_99 | AC | 2 ms
6,940 KB |
testcase_100 | AC | 2 ms
6,944 KB |
testcase_101 | WA | - |
testcase_102 | AC | 3 ms
6,940 KB |
testcase_103 | AC | 2 ms
6,940 KB |
testcase_104 | AC | 3 ms
6,940 KB |
testcase_105 | AC | 2 ms
6,944 KB |
testcase_106 | AC | 2 ms
6,944 KB |
testcase_107 | AC | 2 ms
6,940 KB |
testcase_108 | AC | 2 ms
6,944 KB |
testcase_109 | AC | 2 ms
6,940 KB |
testcase_110 | WA | - |
testcase_111 | WA | - |
testcase_112 | WA | - |
testcase_113 | TLE | - |
testcase_114 | -- | - |
testcase_115 | -- | - |
testcase_116 | -- | - |
testcase_117 | -- | - |
testcase_118 | -- | - |
ソースコード
#include<iostream> #include<algorithm> #include<string> using namespace std; long long K, L, R, U, V; string Y; long long sums(long long P, long long Q) { if (P >= (1LL << Q))return (1LL << 62); if (P < 0)return -(1LL << 62); long long ret = 0, U = P; for (int i = 1; i <= Q; i++) { ret += ((U + 1) / 2) * to_string(i*i).size(); U -= (U + 1) / 2; } return ret; } long long modpow(long long a, long long b, long long m) { long long p = 1, q = a; for (int i = 0; i < 63; i++) { if ((b / (1LL << i)) % 2 == 1)p *= q; q *= q; p %= m; q %= m; } return p; } void search() { //左の境界を探索 long long L1 = -1, R1 = (1LL << K) + 1, M1; while (true) { M1 = (L1 + R1) / 2; long long Y1 = sums(M1 - 1, K), Y2 = sums(M1, K); if (Y1 < L && Y2 >= L) { U = M1; U++; if (Y2 - L >= 1) { long long I = M1, J = 1; while (I % 2 == 0) { I /= 2; J++; } Y += to_string(J*J).substr(to_string(J).size() - (Y2 - L), (Y2 - L)); } break; } if (Y2 < L)L1 = M1; if (Y1 >= L)R1 = M1; } //右の境界を探索 L1 = -1; R1 = (1LL << K) + 1; while (true) { M1 = (L1 + R1) / 2; long long Y1 = sums(M1, K), Y2 = sums(M1 + 1, K); if (Y1 <= R && Y2 > R) { V = M1; if (R - Y1 >= 1) { long long I = M1, J = 1; I++; while (I % 2 == 0) { I /= 2; J++; } Y += to_string(J*J).substr(0, (R - Y1)); } break; } if (Y2 <= R)L1 = M1; if (Y1 > R)R1 = M1; } } int main() { cin >> K >> L >> R; L--; if (R > sums((1LL << K) - 1, K)) { cout << "-1" << endl; return 0; } search(); //端数部分の和と積を求める long long wa = 0, seki = 1; for (int i = 0; i < Y.size(); i++) { long long G = (Y[i] - '0'); if (G == 0)G = 10; wa += G; seki *= G; } //区間の部分の積と和を求める U--; for (int i = 1; i <= K; i++) { long long U1 = (U + 1) / 2; long long U2 = (V + 1) / 2; string T = to_string(i*i); long long w1 = 0, w2 = 1; for (int j = 0; j < T.size(); j++) { long long G = (T[j] - '0'); if (G == 0)G = 10; w1 += G; w2 *= G; } //cout << U2 - U1 << ' ' << U << ' ' << V << endl; wa += w1*(U2 - U1); seki *= modpow(w2, U2 - U1, 1000000007); seki %= 1000000007; U -= U1; V -= U2; } //出力 cout << wa << ' ' << seki << endl; return 0; }