- #include <bits/stdc++.h>
- using namespace std;
- long long int a[201][201];
- int main()
- {
- long long int ts, cs = 1;
- cin>>ts;
- while(ts--){
- string s;
- cin>>s;
- long long int l = s.length();
- for(long long int i = 0; i <=l; i++){
- a[i][i] = 1;
- }
- for(long long int len = 2; len <=l; len++){
- for(long long int i = 0; s[i+len-1]; i++){
- long long int j = i+len-1;
- a[i][j] = a[i+1][j] + a[i][j-1]-a[i+1][j-1];
- if(s[i]==s[j]){
- a[i][j] += a[i+1][j-1] + 1;
- }
- }
- }
- /*
- for(int i = 0; i <l; i++){
- for(int j = 0; j <l; j++){
- cout<<a[i][j]<<" ";
- }
- cout<<endl;
- }
- */
- printf("Case %lld: %lld\n", cs++,a[0][l-1]);
- }
- return 0;
- }
Thursday 27 July 2017
Lightoj 1025 - The Specials Menu
Subscribe to:
Post Comments (Atom)
Most Featured Post
Lightoj 1159 - Batman
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
-
Problem link: Problem Analysis: It is actually a basic Bisection problem , as we can see here we can not actually find a formula fo...
-
http://lightoj.com/volume_showproblem.php?problem=1382 Problem analysis: This is a rare problem i wrote about so far. After much strugg...
No comments:
Post a Comment