結果
| 問題 |
No.528 10^9と10^9+7と回文
|
| ユーザー |
ytft
|
| 提出日時 | 2021-03-19 18:39:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 833 bytes |
| コンパイル時間 | 1,660 ms |
| コンパイル使用メモリ | 172,044 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 14:34:39 |
| 合計ジャッジ時間 | 2,893 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 WA * 9 |
ソースコード
#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=0;i<p/2;i++){
if(N[i]>N[p-1-i]){
ans=0;
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