Nspyia


私信TA

用户名:nspyia

访问量:14257

签 名:

等  级
排  名 1396
经  验 2823
参赛次数 2
文章发表 14
年  龄 0
在职情况 学生
学  校 yb
专  业

  自我简介:

解题思路:

        1.输入s
        2.用set保存所有长度为8的s的子串 //方便判断

        3.输入n,循环n次:

            1).输入密码串s

            2).排序s,方便用库函数遍历所有排列组合

            3).遍历时,如果st中有这个字符串则ans++

        4.输出ans
注意事项:
        
参考代码:

#include<bits/stdc++.h>
using namespace std;

string s;
set<string> st;
int main(){
    cin>>s;
    int n=s.length();
    for(int i=0;i+7<n;i++)st.insert(s.substr(i,8));//set长度为8的子串
    cin>>n;
    int ans=0;
    while(n--){
    	cin>>s;
    	sort(s.begin(),s.end());
    	do{
    		if(st.count(s))ans++;
    	}while(next_permutation(s.begin(),s.end()));
    }
    cout<<ans<<endl;
}


 

0.0分

4 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

蛮高级的,但耗时还是比普通做法高那么一丢丢,哈哈哈,蛮好的
2020-08-29 10:54:58
很好利用了next_permutation()函数的用法
2020-08-07 17:11:32
这个牛批
2019-05-14 15:28:16
  • «
  • 1
  • »