結果

問題 No.1580 I like Logarithm!
ユーザー V_Melville
提出日時 2021-07-03 02:02:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 464 bytes
コンパイル時間 4,596 ms
コンパイル使用メモリ 251,176 KB
最終ジャッジ日時 2025-01-22 17:05:39
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>

using std::cin;
using std::cout;
using namespace atcoder;
using mint = modint1000000007;
using std::string;
using ll = long long;

int main() {
	int a;
	string b;
	cin >> a >> b;
	int n = b.size();
	reverse(b.begin(), b.end());
	
	mint ans, mul = 1, t;
	for (int i = 0; i < n; ++i) {
		ans -= mul - 1;
		t += mint(b[i] - '0') * mul;
		mul *= a;
	}
	
	ans += t * (n - 1);
	
	cout << ans.val() << '\n';
	
	return 0;
}
0