結果
問題 | No.1580 I like Logarithm! |
ユーザー | the-xin |
提出日時 | 2021-07-02 23:10:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 501 bytes |
コンパイル時間 | 677 ms |
コンパイル使用メモリ | 67,584 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-29 12:59:37 |
合計ジャッジ時間 | 1,934 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 39 |
ソースコード
#include<iostream> #include<cstring> #include<algorithm> using namespace std; typedef long long LL; const LL mod=1e9+7,N=1e6+10; char s[N]; int main(){ LL a; cin>>a>>(s+1); int n=strlen(s+1); long long ans=0,t=0,pre1=1,pre2=1; for(int i=n;i>=1;i--){ if(i!=1){ pre1=1ll*pre1*a%mod; ans=ans+1ll*(pre1-pre2+mod)*(n-i)%mod; ans%=mod; pre2=1ll*pre2*a%mod; } } for(int i=1;i<=n;i++){ t=(1ll*t*a+(s[i]-'0'))%mod; } ans+=1ll*(t-pre2+1+mod)*(n-1); ans%=mod; cout<<ans; return 0; }