呵呵,哭了
来源:互联网 发布:2016年7月出口数据 编辑:程序博客网 时间:2024/05/17 22:55
#include <vector>
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int n1,n2,n3;
int vv1,vv2,w1,w2,w3;
vector<int> v1{0,0,0};
vector<int> v2{0,0,0};
bool equal(vector<int> &vec1,vector<int> &vec2)
{
v1.clear();
v2.clear();
for(auto v:vec1)
v1.push_back(v);
for(auto v:vec2)
v2.push_back(v);
sort(v1.begin(),v1.end());
sort(v2.begin(),v2.end());
w1=v2[1]-v2[0];
w2=v2[2]-v2[1];
w3=v2[2]-v2[0];
if((w1==v1[0]&&w2==v1[1]&&w3==v1[2]&&v2[0]!=0&&v2[1]!=0&&v2[2]!=0)||
(w1=v1[1]&&w2==v1[0]&&w3==v1[2]&&v2[0]!=0&&v2[1]!=0&&v2[2]!=0))
return true;
else
return false;
}
vector<int> docount(string &s)
{
n1=0;
n2=0;
n3=0;
for(auto word:s)
{
if(word=='R')
n1++;
if(word=='Y')
n2++;
if(word=='B')
n3++;
}
vector<int> num{n1,n2,n3};
return num;
}
int main()
{
vector<int> vec1;
vector<int> vec2;
int v;
int N;
int ret=0;
while(cin>>v)
vec1.push_back(v);
string word;
cin.clear();
cin>>word;
N=word.length();
string temp;
int index=0;int step=2;
int ret2=2;
while(index+step<=N)
{
temp=word.substr(index,step);
vec2=docount(temp);
if(equal(vec1,vec2))
{
if(ret<ret2)
ret=ret2;
cout<<temp<<endl;
index=index+step;
step=2;
ret2=2;
}
if(!equal(vec1,vec2))
{
step++;
ret2++;
}
}
ret2--;
if (ret<ret2)
ret=ret2;
cout<<ret<<endl;
}
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int n1,n2,n3;
int vv1,vv2,w1,w2,w3;
vector<int> v1{0,0,0};
vector<int> v2{0,0,0};
bool equal(vector<int> &vec1,vector<int> &vec2)
{
v1.clear();
v2.clear();
for(auto v:vec1)
v1.push_back(v);
for(auto v:vec2)
v2.push_back(v);
sort(v1.begin(),v1.end());
sort(v2.begin(),v2.end());
w1=v2[1]-v2[0];
w2=v2[2]-v2[1];
w3=v2[2]-v2[0];
if((w1==v1[0]&&w2==v1[1]&&w3==v1[2]&&v2[0]!=0&&v2[1]!=0&&v2[2]!=0)||
(w1=v1[1]&&w2==v1[0]&&w3==v1[2]&&v2[0]!=0&&v2[1]!=0&&v2[2]!=0))
return true;
else
return false;
}
vector<int> docount(string &s)
{
n1=0;
n2=0;
n3=0;
for(auto word:s)
{
if(word=='R')
n1++;
if(word=='Y')
n2++;
if(word=='B')
n3++;
}
vector<int> num{n1,n2,n3};
return num;
}
int main()
{
vector<int> vec1;
vector<int> vec2;
int v;
int N;
int ret=0;
while(cin>>v)
vec1.push_back(v);
string word;
cin.clear();
cin>>word;
N=word.length();
string temp;
int index=0;int step=2;
int ret2=2;
while(index+step<=N)
{
temp=word.substr(index,step);
vec2=docount(temp);
if(equal(vec1,vec2))
{
if(ret<ret2)
ret=ret2;
cout<<temp<<endl;
index=index+step;
step=2;
ret2=2;
}
if(!equal(vec1,vec2))
{
step++;
ret2++;
}
}
ret2--;
if (ret<ret2)
ret=ret2;
cout<<ret<<endl;
}
0 0
- 呵呵,哭了
- 呵呵了。。
- 太高兴了,呵呵!!
- 呵呵!有点晕了.....
- 呵呵...我来了
- 呵呵 快休息了
- 呵呵!换工作了!
- 呵呵,Blog开通了!!!
- 呵呵,终于开张了!!
- 呵呵,我来了。。。。
- 明天回家了,呵呵
- 睡觉了,呵呵
- 终于回来了,呵呵
- 快十一了,呵呵
- 呵呵,blog 变了
- 呵呵,终于成功了
- BLOG开放了,呵呵
- 今天签约了.呵呵~~~~~~~
- 30-语言入门-30-分数加减法
- Trapping Rain Water--LeetCode
- hdu 1258题解
- 31-语言入门-31-字符串替换
- 简单的UDP通信
- 呵呵,哭了
- Fibonacci数列一些性质
- I2S,PCM,IOM-2,I2C,SPI,UART,GPIO
- 数据结构(严蔚敏)之二——链表的c语言实现
- 第五周 【项目1-体验常成员函数】
- java同步器——2——笔记
- 念数字
- 用Java实现读取计算机目录的文件
- iphone程序启动互相调用, 打开其他程序