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. 北邮新生排位赛1解题报告a-c

    <div class="page-header" style="padding-bottom: 9px; margin: 20px 0px 30px; border ...

  2. POJ 1436 区间染色

    Horizontally Visible Segments Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 4507   Ac ...

  3. C-crash的方法

    #include <iostream> using namespace std; int main() { #if 0 //devide by 0 ; ; double d = i/j; ...

  4. 戴文的Linux内核专题:01介绍

    转自Linux中国 译者按:本文作者戴文.科利尔.约翰逊(Devyn Collier Johnson)今年才19岁,但是他在Linux内核.人工智能.编程语言方面拥有丰富的经验,本文是其在linux. ...

  5. ctime、atime

    Linux系统文件有三个主要的时间属性,分别是ctime(change time, 而不是create time), atime(access time), mtime(modify time).后来 ...

  6. [windows操作系统]windows模块

    smss.exe csrss.exe    Client/Server Runtime Server Subsystem

  7. 监听cell 滑动到 摸个分区

    //滑动过程中 - (void)scrollViewDidScroll:(UIScrollView *)scrollView { //    NSLog(@"000---%ld", ...

  8. 解决C#的64位打包程序,在64位机器上运行出现BadImageFormatException异常。

    转载自:http://msdn.microsoft.com/zh-cn/library/system.badimageformatexception%28v=vs.100%29.aspx BadIma ...

  9. ios上架

    1.登录developer.apple.com 2.点击member center后 进下图 3.点击certificates Identifiers进下图 4.点击Certificates进下图,首 ...

  10. oracle 之关键字exists

    -----------------------------------------------------------------------SQL中EXISTS的用法---------------- ...