結果
問題 | No.1580 I like Logarithm! |
ユーザー | shiomusubi496 |
提出日時 | 2021-07-02 22:03:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 380 bytes |
コンパイル時間 | 2,234 ms |
コンパイル使用メモリ | 192,628 KB |
最終ジャッジ日時 | 2025-01-22 16:01:27 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 39 |
ソースコード
#include<bits/stdc++.h> #define int long long using namespace std; constexpr int mod=1000000007; signed main(){ int A; string B; cin>>A>>B; int N=B.size(); int ans=0; int p=1; for(int i=0;i<N-1;i++,(p*=A)%=mod){ (ans+=i*(p*(A-1)%mod))%=mod; } int m=0; for(char c:B){ ((m*=A)+=c-'0')%=mod; } m=(m-p+1+mod)%mod; cout<<(ans+m*(N-1)%mod)%mod<<endl; }