結果
問題 |
No.1580 I like Logarithm!
|
ユーザー |
|
提出日時 | 2021-07-08 11:43:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 646 bytes |
コンパイル時間 | 522 ms |
コンパイル使用メモリ | 66,244 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-01 12:29:08 |
合計ジャッジ時間 | 1,937 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 39 |
ソースコード
#include <iostream> #include <algorithm> #include <string> using namespace std; long long md = 1000000007; int main() { ios::sync_with_stdio(false); cin.tie(0); int a; string s; cin >> a >> s; int n = s.length(); long long ans = 0, r = 1; for (int i = 1; i < n; i++) { ans = (ans + r * (s[n - i] - '0')) % md; r = (r * a) % md; } ans = ((ans + 1LL) * (n - 1)) % md; r = 1; for (int i = 1; i < n; i++) { ans = (ans + r * (a - 1) * (i - 1)) % md; r = (r * a) % md; } ans = (ans + (long long)(s[0] - '1') * (n - 1) * r) % md; cout << ans << '\n'; return 0; }