結果
問題 |
No.599 回文かい
|
ユーザー |
![]() |
提出日時 | 2016-06-03 20:15:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,727 ms / 4,000 ms |
コード長 | 456 bytes |
コンパイル時間 | 680 ms |
コンパイル使用メモリ | 69,760 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-08 06:43:23 |
合計ジャッジ時間 | 6,270 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
#include <iostream> #include <vector> #include <string> using namespace std; const long long mod = 1000000007; int main(){ string s; cin >> s; int n = s.size(); vector<long long> dp(n+1, 0); dp[0] = 1; long long ans = 1; for(int i=1; i<=n/2; i++){ for(int j=0; j<i; j++){ if(!dp[j]) continue; if(s.substr(j, i-j) == s.substr(n-i,i-j)){ (dp[i] += dp[j]) %= mod; } } (ans += dp[i]) %= mod; } printf("%lld", ans); return 0; }