BestCoder Round #89 1001 Fxx and string
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5944
分析:
竟然 i,j,k成等比数列,即i*k = j*j,还要满足 j|i or j|k。
不防设:
j = i*j;
k = i*j*j,就满足那两个条件了,然后遍历这两个条件。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; int main()
{
int t;
cin>>t;
while(t--) { char s[+];
scanf("%s",s+);
int len = strlen(s+);
int ans = ;
for(int i=;i<=len;i++) {
for(int j=;j*j*i<=len;j++) {
int J = i*j,k=i*j*j;
if(s[i]=='y'&&s[J]=='r'&&s[k]=='x') ans++;
else if(s[i]=='x'&&s[J]=='r'&&s[k]=='y') ans++; }
}
cout<<ans<<endl; }
return ;
}
BestCoder Round #89 1001 Fxx and string的更多相关文章
- HDU 5945 / BestCoder Round #89 1002 Fxx and game 单调队列优化DP
Fxx and game 问题描述 青年理论计算机科学家Fxx给的学生设计了一款数字游戏. 一开始你将会得到一个数\:XX,每次游戏将给定两个参数\:k,tk,t, 任意时刻你可以对你的数执行下面 ...
- BestCoder Round #89 1002 Fxx and game
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5945 分析: 很容易想到用bfs,然而会超时,几乎是O(xt)了 这里用单调队列优化, 首先反着来,f ...
- 贪心 BestCoder Round #39 1001 Delete
题目传送门 /* 贪心水题:找出出现次数>1的次数和res,如果要减去的比res小,那么总的不同的数字tot不会少: 否则再在tot里减去多余的即为答案 用set容器也可以做,思路一样 */ # ...
- 暴力 BestCoder Round #41 1001 ZCC loves straight flush
题目传送门 /* m数组记录出现的花色和数值,按照数值每5个搜索,看看有几个已满足,剩下 5 - cnt需要替换 ╰· */ #include <cstdio> #include < ...
- BestCoder Round #89 02单调队列优化dp
1.BestCoder Round #89 2.总结:4个题,只能做A.B,全都靠hack上分.. 01 HDU 5944 水 1.题意:一个字符串,求有多少组字符y,r,x的下标能组成等比数列 ...
- BestCoder Round #89
过了这么久才来写-- BC的后两道题好难--(第二道题也不怎么简单--) 1001 Fxx and string 正着倒着枚举一次就ok #include<iostream> #inclu ...
- BestCoder Round #81 (div.2) 1004 String(动态规划)
题目链接:BestCoder Round #81 (div.2) 1003 String 题意 中文题,上有链接.就不贴了. 思路 枚举起点i,计算能够达到k个不同字母的最小下标j,则此时有子串len ...
- 暴力 BestCoder Round #46 1001 YJC tricks time
题目传送门 /* 暴力:模拟枚举每一个时间的度数 详细解释:http://blog.csdn.net/enjoying_science/article/details/46759085 期末考结束第一 ...
- 字符串处理 BestCoder Round #43 1001 pog loves szh I
题目传送门 /* 字符串处理:是一道水题,但是WA了3次,要注意是没有加'\0'的字符串不要用%s输出,否则在多组测试时输出多余的字符 */ #include <cstdio> #incl ...
随机推荐
- Linux内核模块简单示例
1. Linux 内核的整体结构非常庞大,其包含的组件也非常多,使用这些组件的方法有两种: ① 直接编译进内核文件,即zImage或者bzImage(问题:占用内存过多) ② 动态添加 * 模块本身并 ...
- python3 发送邮件添加附件
from email.header import Headerfrom email.mime.application import MIMEApplicationfrom email.mime.mul ...
- Java 目录和文件的复制
1.复制一个目录及其子目录.文件到另外一个目录 //复制一个目录及其子目录.文件到另外一个目录 public void copyFolder(File src, File dest) throws I ...
- esper(2)-事件类型
1.pojo package com.ebc.eventtype.pojo.pojo1; import cn.hutool.core.collection.CollUtil; import com.e ...
- linux面试题:删除一个目录下的所有文件,但保留一个指定文件
面试题:删除一个目录下的所有文件,但保留一个指定文件 解答: 假设这个目录是/xx/,里面有file1,file2,file3..file10 十个文件 [root@oldboy xx]# touch ...
- vue入门----------scss的配置使用
1.安装相应的依赖 cnpm install sass-loader --save-dev cnpm install node-sass --save-dev 2.在build文件下的webpack. ...
- The 'gridview' module MUST be setup in your Yii configuration file.
解决方法:common的config的main.php中添加 'gridview' => ['class' => 'kartik\grid\Module'], 在vender的compos ...
- web前端开发道路
https://github.com/z-jingjie/developer-roadmap-zh-CN
- ES6结构赋值
解构赋值 从ES6开始,JavaScript引入了解构赋值,可以同时对一组变量进行赋值. 什么是解构赋值?我们先看看传统的做法,如何把一个数组的元素分别赋值给几个变量: var array = ['h ...
- spring事务的传播性
<!--配置事务传播特性 --><tx:advice id = "txAdvice" transaction-manager = "txManage&q ...