[BC#89A]Fxx and string
来源:互联网 发布:jsp asp php 编辑:程序博客网 时间:2024/05/22 13:57
题目大意
给定一个字符串求有多少三元组(i,j,k)满足i、j、k形成等比数列,且s[i]=’y’,s[j]=’r’,s[k]=’x’
瞎做
枚举i和j即可求k,这个枚举是n log n的。
注意不一定i
#include<cstdio>#include<algorithm>#include<cstring>#define fo(i,a,b) for(i=a;i<=b;i++)using namespace std;typedef long long ll;const int maxn=10000+10;char s[maxn];int i,j,k,l,t,n,m,ca;ll ans;int main(){ scanf("%d",&ca); while (ca--){ scanf("%s",s+1); n=strlen(s+1); ans=0; fo(i,1,n) if (s[i]=='y') fo(j,2,n/i){ if ((ll)i*j*j>n) break; if (s[i*j]!='r') continue; if (s[i*j*j]=='x') ans++; } fo(i,1,n) if (s[i]=='x') fo(j,2,n/i){ if ((ll)i*j*j>n) break; if (s[i*j]!='r') continue; if (s[i*j*j]=='y') ans++; } printf("%lld\n",ans); }}
0 0
- [BC#89A]Fxx and string
- [BC#89B]Fxx and game
- BestCoder Round #89 1001 Fxx and string
- BEST CODE#89 Fxx and string
- bestcode Fxx and string
- Fxx and string
- HDU5944 Fxx and string
- *Fxx and string
- bestcoder-Fxx and string
- Fxx and string
- 水题-fxx and string
- Fxx and string
- Fxx and game(bc上的题)
- hdu 5944 Fxx and string
- hdu 5944 Fxx and string
- HDU 5944 Fxx and string
- hdu 5944 Fxx and string
- hdu5944(Fxx and string)
- hibernate session
- Android 自定义下拉列表
- ARP讲解
- Scala集合
- PopupWindow的使用以及ArrayAdatper.notifyDataSetChanged()无效详解
- [BC#89A]Fxx and string
- Java并发基础总结
- mysql关于输入密码后闪退
- 100道动态规划——6 UVA 1629 Cake slicing 记忆化搜索
- Mybatis-Generator使用(maven项目)
- 初学java的困惑
- php中加密类型和常用的加密函数
- 编译、链接、visual studio 和 cmake 工作
- Xcode文档注释使用总结