結果
| 問題 | No.599 回文かい |
| コンテスト | |
| ユーザー |
conf
|
| 提出日時 | 2017-03-18 01:12:05 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,201 bytes |
| 記録 | |
| コンパイル時間 | 364 ms |
| コンパイル使用メモリ | 62,188 KB |
| 最終ジャッジ日時 | 2026-03-25 21:48:21 |
| 合計ジャッジ時間 | 747 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:6:1: error: 'uint64_t' does not name a type
6 | uint64_t mod_pow(uint64_t a, uint64_t e, uint64_t p){
| ^~~~~~~~
main.cpp:2:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
1 | #include <iostream>
+++ |+#include <cstdint>
2 | using namespace std;
main.cpp: In function 'int main()':
main.cpp:20:5: error: 'uint64_t' was not declared in this scope
20 | uint64_t base=1007,mod=1000000009,hl,hr;
| ^~~~~~~~
main.cpp:20:5: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
main.cpp:22:9: error: 'hl' was not declared in this scope
22 | hl=0;hr=0;
| ^~
main.cpp:22:14: error: 'hr' was not declared in this scope
22 | hl=0;hr=0;
| ^~
main.cpp:24:20: error: 'base' was not declared in this scope
24 | hl=(hl*base+S[j])%mod;
| ^~~~
main.cpp:24:31: error: 'mod' was not declared in this scope
24 | hl=(hl*base+S[j])%mod;
| ^~~
main.cpp:25:20: error: 'mod_pow' was not declared in this scope
25 | hr=(hr+mod_pow(base,i-j,mod)*S[S.size()-j-1])%mod;
| ^~~~~~~
ソースコード
#include <iostream>
using namespace std;
int64_t DP[5002];
uint64_t mod_pow(uint64_t a, uint64_t e, uint64_t p){
uint64_t res = 1;
for(;e>0;e>>=1){
if(e&1)res=(res*a)%p;
a=(a*a)%p;
}
return res;
}
int main(){
string S;
cin>>S;
int64_t ans = 1;
DP[0]=1;
uint64_t base=1007,mod=1000000009,hl,hr;
for(int i=0;i<S.size()/2;i++){
hl=0;hr=0;
for(int j=i;j>=0;j--){
hl=(hl*base+S[j])%mod;
hr=(hr+mod_pow(base,i-j,mod)*S[S.size()-j-1])%mod;
// cout<<S.substr(j,i-j+1)<<' '<<S.substr(S.size()-i-1,i-j+1)<<' '<<hl<<' '<<hr<<' '<<S[j]<<' '<<S[S.size()-j-1]<<endl;
if(hl==hr){
DP[i+1]+=DP[j];
DP[i+1]%=1000000007;
}
}
/*
for(int j=0;j<=i;j++){
cout<<S.substr(j,i-j+1)<<' '<<S.substr(S.size()-i-1,i-j+1)<<endl;
if(S.substr(j,i-j+1)==S.substr(S.size()-i-1,i-j+1)){
cout<<'A'<<endl;
DP[i+1]+=DP[j];
DP[i+1]%=1000000007;
}
}
*/
ans+=DP[i+1];
ans%=1000000007;
}
cout<<ans<<endl;
return 0;
}
conf