Fxx and string

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 507    Accepted Submission(s): 224

Problem Description
Young theoretical computer scientist Fxx get a string which contains lowercase letters only.

The string S

contains n

lowercase letters S1S2…Sn

.Now Fxx wants to know how many three tuple (i,j,k)

there are which can meet the following conditions:

1、i,j,k

are adjacent into a geometric sequence.

2、Si=

'y

',Sj=

'r

',Sk=

'x

'.

3.Either j|i or j|k

 
Input
In the first line, there is an integer T(1≤T≤100)

indicating the number of test cases.

T

lines follow, each line contains a string, which contains only lowercase letters.(The length of string will not exceed 10000

).

 
Output
For each case, output the answer.
 
Sample Input
2
xyyrxx
yyrrxxxxx
 
Sample Output
0
2
 
Source
 
题意:
题解:给你一个字符串暴力求 有多少组 ‘y’ ‘r’ ‘x’ 位置成等比数列  注意逆序!
 /******************************
code by drizzle
blog: www.cnblogs.com/hsd-/
^ ^ ^ ^
O O
******************************/
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<math.h>
#include<vector>
#include<string>
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
#define A first
#define B second
const int mod=;
const int MOD1=;
const int MOD2=;
const double EPS=0.00000001;
typedef __int64 ll;
const ll MOD=;
const int INF=;
const ll MAX=1ll<<;
const double eps=1e-;
const double inf=~0u>>;
const double pi=acos(-1.0);
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
int t;
char a[];
int main()
{
scanf("%d",&t);
for(int i=;i<=t;i++)
{
int sum=;
scanf("%s",a+);
int len=strlen(a+);
for(int j=;j<=len;j++)
{
if(a[j]=='y')
{
for(int k=;;k++)
{
if(j*k*k>len)
break;
if(a[j*k]=='r'&&a[j*k*k]=='x')
{
sum++;
}
}
}
if(a[j]=='x')
{
for(int k=;;k++)
{
if(j*k*k>len)
break;
if(a[j*k]=='r'&&a[j*k*k]=='y')
{
sum++;
}
}
}
}
printf("%d\n",sum);
}
return ;
}
 
 

HDU 5944 暴力的更多相关文章

  1. HDU 5944 Fxx and string(暴力/枚举)

    传送门 Fxx and string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Othe ...

  2. HDU 5944 Fxx and string (暴力)

    题意:给定一个字符串,问有多少个三元组满足 i, j, k组成一个等比数列,并且s[i] = 'y', s[j] = 'r', s[k] = 'x',且j/i ,j/k中至少一个是整数. 析:直接暴力 ...

  3. HDU 6351暴力枚举 6354计算几何

    Beautiful Now Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)T ...

  4. hdu 5944 Fxx and string

    \:nn,下标从1开始,第\:i\:i位的字母为\:s_is​i​​,现在Fxx想知道有多少三元组\:(i,j,k)\:(i,j,k)满足下列条件 1.i,j,k\:i,j,k三个数成等比数列 2.s ...

  5. hdu 4039 暴力

    思路:用map将每个字符串与一个数字进行对应,然后暴力统计就好了 #include<cstring> #include<iostream> #include<cstdio ...

  6. hdu 4952 暴力

    http://acm.hdu.edu.cn/showproblem.php?pid=4952 给定x,k,i从1到k,每次a[i]要是i的倍数,并且a[i]大于等于a[i-1],x为a0 递推到下一个 ...

  7. hdu 4708(暴力+找规律)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4708 思路:由于N不大,并且我们可以发现通过旋转得到的4个对角线的点的位置关系,以及所要旋转的最小步数 ...

  8. HDU - 6183 暴力,线段树动态开点,cdq分治

    B - Color itHDU - 6183 题目大意:有三种操作,0是清空所有点,1是给点(x,y)涂上颜色c,2是查询满足1<=a<=x,y1<=b<=y2的(a,b)点一 ...

  9. HDU 5386 暴力

    题目 也是个坑题,可惜没有发现这是个水题,被矩阵的气势吓住了,其实后来做出来的人挺多,就应该想到没那么难了.(两个队友陷入DP无法自拔,没有想换题的打算). 题意:告诉初始矩阵,目的矩阵,告诉n个步骤 ...

随机推荐

  1. No suitable driver found for jdbc:mysql://localhost/dbname

    把mysql-connector-java的jar包放入jdk/jre/lib/ext文件下

  2. BindingNavigator操作DatagridView的数据

    参考 http://wenku.baidu.com/link?url=NWfEfArPZvDO_aI-xEKBHVGoZY9wQO_Oty_GCsGLiPspheCzFYLf_dytuWAqN2_0A ...

  3. c#中使用servicestackredis操作redis

    下载地址: https://github.com/mythz/ServiceStack.Redis 添加dll引用: using ServiceStack.Common.Extensions;usin ...

  4. IP数据报的格式

    1. IP数据报首部的固定部分中的各字段 ①版本:占4位,指IP协议的版本.通信双方使用的 IP协议版本必须一致.日前广泛使用的 IP协议版本号为 4 (即 IPv4). IPv6 目前还处于起步阶段 ...

  5. Windows的同步I/O和异步I/O

    同步I/O操作 执行步骤 1.        程序通过FileStream对象来打开磁盘文件,然后调用Read方法(内部调用Win32 ReadFile函数),从文件中读取数据.这时,线程从托管代码转 ...

  6. 【python】dict。字典

    特点:以空间换取时间,使用HASH算法通过key算出了value的内存地址,建立索引,拿到key后查找速度快,但内存浪费多 因为是用key值算的内存地址,所以key为不可变变量 (set,和dict类 ...

  7. Cookie 与Session 的区别(转载)

    原地址: http://www.cnblogs.com/shiyangxt/archive/2008/10/07/1305506.html 两个都可以用来存私密的东西,同样也都有有效期的说法. 区别在 ...

  8. Bayeux

    Bayeux是一种用来在客户端和服务器端传输低延迟的异步消息(主要通过http)的一种协议.它定义的消息通过命名通道进行路由并且能够进行交互传 送:server -> client, clien ...

  9. 无法为表空间 ***中的段创建 INITIAL 区

    这是由于表空间不足引起的. 具体错误: 解决方案:扩展表空间

  10. chrom,firefox,ie不能上网,百度浏览器却可以。。。

    chrome和ie提示DNS查找失败,但是百度浏览器没任何问题,这是什么情况... 尝试很多方法后无用,命令行执行很多命令,无用, 试一下阿里的 DNS: 首选:223.5.5.5备用:223.6.6 ...