0
This program in C is showing me some errors. Can you please help me??
#include <stdio.h> #include <string.h> #include <stdlib.h> const int maxn = 1e7+5; char s[maxn]; int dp[maxn]; long long p1=131, t1=1; long long p2=127, t2=1; long long h1=0, rh1=0; long long h2=0, rh2=0; int main() { scanf("%s",s+1); int ans = 0; int l = strlen(s+1); for(int i=1;i<=l;i++) { h1=h1*p1+s[i]; rh1=s[i]*t1+rh1; t1=t1*p1; h2=h2*p2+s[i]; rh2=s[i]*t2+rh2; t2=t2*p2; if(h1==rh1&&h2==rh2) dp[i]=dp[i/2]+1; ans+=dp[i]; } printf("%d",ans); return 0; }
5 Answers
+ 2
Shaxzoda Sherzodovna
May you not answer like that in discussion forum.
Let it be to those who knows.
Follow community guidelines of the forum from here-
https://googleweblight.com/i?u=https://www.sololearn.com/Content-Creation-Guidelines/&hl=en-IN
+ 1
Try deleting this:Â
const int maxn = 1e7+5;
and givingvalues to them:
char s[any number]
int dp[any number]
+ 1
I'm not sure what your show isabout.
0
@Marco thanks for replying to my question once again and I really appreciate the way you are taking part in discussion forum. My question is based on a problem from codeforces called 7D. Palindrome Degree here is a link for that problem https://codeforces.com/problemset/problem/7/D
As you suggested to use any number instead of 1e7 + 5, I tried that also still it is throwing me back some errors.
- 4
Oh i dont know C