結果
| 問題 |
No.528 10^9と10^9+7と回文
|
| ユーザー |
ytft
|
| 提出日時 | 2021-03-19 18:42:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 1,000 ms |
| コード長 | 896 bytes |
| コンパイル時間 | 1,798 ms |
| コンパイル使用メモリ | 170,460 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 14:40:18 |
| 合計ジャッジ時間 | 2,838 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
cin>>S;
int p;
p=S.size();
vector<int> N(p);
for(int i=0;i<p;i++){
N[i]=S[i]-'0';
}
long long ans=1;
long long temp;
vector<long long> MOD={1000000000,1000000007};
for(int j=0;j<2;j++){
ans=1;
for(int i=p/2-1;i>=0;i--){
if(N[i]>N[p-1-i]){
ans=0;
break;
}else if(N[i]<N[p-1-i]){
break;
}
}
temp=1;
for(int i=(p-1)/2;i>0;i--){
ans=(ans+temp*N[i])%MOD[j];
temp=(temp*10)%MOD[j];
}
ans=(ans+temp*(N[0]-1))%MOD[j];
temp=9;
for(int i=1;i<p;i++){
ans=(ans+temp)%MOD[j];
if(i%2==0){
temp=(temp*10)%MOD[j];
}
}
cout<<ans<<endl;
}
}
ytft