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. 超简单的NDK单步调试方法

    令人兴奋的是,ADTr20已经支持JNI单步调试,再也不需要如上这么麻烦的步骤了 你现在需要做的只需以下2步: 1.使用ndk-build编译时,加上如下参数NDK_DEBUG=1,之后生成so文件之 ...

  2. 3.精通前端系列技术之深入学习Jquery(一)

    使用Jquery的好处: •简化JS的复杂操作 •不再需要关心兼容性(原生js获取元素样式.事件需要做兼容性) •提供大量实用方法 1.选择网页元素 <!DOCTYPE html PUBLIC ...

  3. 编译哈工大语言技术平台云LTP(C++)源码及LTP4J(Java)源码

    转自:编译哈工大语言技术平台云LTP(C++)源码及LTP4J(Java)源码 JDK:java version “1.8.0_31”Java(TM) SE Runtime Environment ( ...

  4. asp.net 代码 注意点

    1. 模糊查询时,注意要去掉空格 前台: <input id="txtQJBH" type="text" runat="server" ...

  5. GoldenGate中使用strcat和strext进行数据转换

    在OGG中可以对源字段的内容进行合并或拆分,从而实现类似于“ETL”的功能.strcat(s1,s2,s3,,,):用于合并字串:strext(str, start, end):用于获取指定位置的字串 ...

  6. 《day18_String练习_基本类型包装类_集合入门》

    package cn.itcast.api.String.test; public class StringTest_1 { public static void main(String[] args ...

  7. poj2104 线段树 划分树

    学习:http://www.cnblogs.com/pony1993/archive/2012/07/17/2594544.html 划分树的build: 划分树是分层构建的,在构建的t层时,我们可以 ...

  8. hadoop 中对Vlong 和 Vint的压缩方法

    hadoop 中对java的基本类型进行了writeable的封装,并且所有这些writeable都是继承自WritableComparable的,都是可比较的:并且,它们都有对应的get() 和 s ...

  9. Eclipse卡死问题解决办法

    偶尔浏览到几个eclipse卡死的文章,收集一下. 1.  eclipse 3.6卡死 eclipse自动提示反应慢,或者卡死, 有人说这是eclipse 3.6的版本bug, 但是3.5版本好像也有 ...

  10. 《view programming guide for iOS 》之可以使用动画效果的属性

    frame—Use this to animate position and size changes for the view.  ,框架,可以视图动态改变大小和位置 bounds—Use this ...