結果
問題 | No.1580 I like Logarithm! |
ユーザー |
👑 ![]() |
提出日時 | 2021-07-02 22:58:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 668 bytes |
コンパイル時間 | 888 ms |
コンパイル使用メモリ | 67,920 KB |
最終ジャッジ日時 | 2025-01-22 16:44:02 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 39 |
ソースコード
#include <iostream> #include <string> using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) const ull MOD = 1000000007; int main(){ int A; string S; cin >> A >> S; ull ans = 0; ull cnt = 0; for(char c : S){ cnt = cnt * A + (c - '0'); cnt %= MOD; } ans += cnt * (S.size() - 1) % MOD; ull tmp = 0; for(char c : S.substr(1)){ tmp = tmp * A + (A-1); tmp %= MOD; ans += MOD - tmp; ans %= MOD; } cout << ans << endl; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_inst;