結果
| 問題 |
No.1580 I like Logarithm!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-13 16:23:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 415 bytes |
| コンパイル時間 | 1,966 ms |
| コンパイル使用メモリ | 193,916 KB |
| 最終ジャッジ日時 | 2025-02-08 02:42:33 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 39 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int A;
cin>>A;
string B;
cin>>B;
int N=B.size();
long long ans=0,t=1,s=1;
for(int i=0;i<N-1;i++){
s=(s+(B[N-1-i]-48)*t)%mod;
ans=(ans+i*(t*A-t))%mod;
t=t*A%mod;
}
s=(s+(B[0]-48)*t)%mod;
ans=(ans+(N-1)*(s-t))%mod;
if(ans<0)ans+=mod;
cout<<ans<<'\n';
}