6
2
Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
var d,i,j:longint;s:string;
function kt(s:string):boolean;
var i:longint;
begin
for i:=1 to length(s) div 2 do
if s[i]<>s[length(S)-i+1)] then exit (false);
exit(true);
end;
begin
assign(input,'DOIXUNG.INP');reset(input);
assign(output,'DOIXUNG.OUT');rewrite(output);
readln(S);
d:=0;
for i:=1 to length(S) do
for j:=1 to length(S) do
if kt(copy(s,i,j-i+1)) then d:=d+1;
write(d);
close(input);
close(output);
end.
Hãy giúp mọi người biết câu trả lời này thế nào?
/******************************
* @#author : DIW
* @#date : oo / oo / oo *
*******************************/
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("O1")
#pragma GCC optimize("O1")
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,mmx,abm")
#define foru(i,a,b) for(int i=a; i<=b; i++)
#define ford(i,a,b) for(int i=a; i>=b; i--)
#define reset(a,b) memset(a,b,sizeof(a))
#define ll long long
using namespace std;
ll a,b,v,i,dem=0;
long long ktdx(string s)
{
string x=s;
reverse(x.begin(),x.end());
if(s==x)
return 1;
return 0;
}
string s;
int ma=0;
int main()
{
cin>>s;
foru(i,0,s.size()-1)
{
foru(j,i+1,s.size()-1)
{
string x;
x=s.substr(i,j-i+1);
if(ktdx(x)==1)
ma=max(ma,j-i+1);
}
}
cout<<ma;
return 0;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin