hdu 5944 Fxx and string
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdu 5944 Fxx and string相关的知识,希望对你有一定的参考价值。
题意确实有点不清晰,第3点应该是i必须被j整除且j必须被k整除,之后就是循环i,枚举q,暴力解题

#include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; char a[10010]; int main() { int T; scanf("%d",&T); while(T--) { scanf("%s",a+1); int ans=0; int n=strlen(a+1); for(int i=1; i<=n; i++) { if(a[i]==\'y\') for(int j=2; i*j*j<=n; j++) { if(a[i*j]==\'r\'&&a[i*j*j]==\'x\') ans++; } } for(int i=n; i>=1; i--) { if(a[i]==\'y\') for(int j=2; i/j/j>=1; j++) { if((i%j)||(i%(j*j))) continue; if(a[i/j]==\'r\'&&a[i/j/j]==\'x\') ans++; } } printf("%d\\n",ans); } return 0; }
以上是关于hdu 5944 Fxx and string的主要内容,如果未能解决你的问题,请参考以下文章
BestCoder Round #89 1001 Fxx and string