HDU 5944 Fxx and string && BestCoder Round #89 1001(细节)
来源:互联网 发布:盖革计数器知乎 编辑:程序博客网 时间:2024/05/18 06:21
Fxx and string
Accepts: 213
Submissions: 1867
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 131072/65536 K (Java/Others)
问题描述
青年理论计算机科学家Fxx得到了一个只包含小写字母的字符串。字符串的长度为n,下标从1开始,第i位的字母为si,现在Fxx想知道有多少三元组(i,j,k)满足下列条件1、i,j,k三个数成等比数列2、si='y',sj='r',sk='x'3.i/j和k/j中必须有整数
输入描述
第一行一个整数T(1≤T≤100)表示数据组数。接下来T行,每行一个仅包含小写字母的字符串(字符串长度不超过10000)
输出描述
输出共T行。每行一个整数表示答案。
输入样例
2xyyrxxyyrrxxxxx
输出样例
02
代码:
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <queue>#include <map>using namespace std;const int maxn = 1e5;char str[maxn];int main(){ int t; scanf("%d", &t); while(t--) { scanf("%s", str+1); str[0] = ' '; int ans = 0, len = strlen(str);// cout << len << endl; for(int i = 1; i < len; i++) { if(str[i] == 'y') { for(int j = i * 2; j < len; j += i) { if(str[j] == 'r') { int x = j * (j / i); if(x < len) { if(str[x] == 'x') ans++; } } } } if(str[i] == 'x') { for(int j = i * 2; j < len; j += i) { if(str[j] == 'r') { int x = j * (j / i); if(x < len) { if(str[x] == 'y') ans++; } } } } } printf("%d\n", ans); } return 0;}Close
1 0
- HDU 5944 Fxx and string && BestCoder Round #89 1001(细节)
- BestCoder Round #89 1001 /hdu 5944/ Fxx and string
- BestCoder Round #89 1001 Fxx and string
- BestCoder Round #89 1001 /hduoj 5944/Fxx and string
- BestCoder Round #89 1001 & HDU 5944 Fxx and string【字符串,等比数列】
- bestcoder-Fxx and string
- [BestCoder Round #89]Fxx and tree
- 【hdu 5944】Fxx and string(枚举)
- hdu 5944 Fxx and string
- hdu 5944 Fxx and string
- HDU 5944 Fxx and string
- hdu 5944 Fxx and string
- HDU 5944 Fxx and string
- hdu 5944 Fxx and string
- hdu 5944 Fxx and String 暴力(水)
- hdu 5944 Fxx and string【暴力枚举】
- 【HDU 5944 Fxx and string】+ 优化
- HDU 5944 Fxx and string(数学)
- 【Web网站服务器开发】apache和tomcat 阿帕奇和汤姆猫
- JSON.parse()和JSON.stringify()
- 编写函数void change(char *a,char *b,char*c)。 函数功能是首先把b指向的字符串逆向存放,然后将a指向的字符串和b指向的字符串按排列顺序交叉合并到c指向的数组中,两个字
- 无符号数与有符合数的加法
- 线索二叉树的建立与遍历C/C++
- HDU 5944 Fxx and string && BestCoder Round #89 1001(细节)
- HBase 基本原理
- 对N行N列二维数组的每一行排序,偶数行(0当作偶数)由小到大排序,奇数行由大到小排序
- 交换技术-基于cisco设备
- 【Web网站服务器开发】Apache 和 Tomcat的区别及配置
- 初学Android时遇到的一些错误及解决办法——之一
- 2.Controller
- 找出符合以下条件的Troitsky数,将该数的首位数字移动到末位数字之后得到的数是原数的整数倍 例如:将142857的首位数字1移动到末位之后得到的数是428571,而428571=3*1
- git 配置用户名和邮箱