zoukankan      html  css  js  c++  java
  • password加密问题

    password加密问题

    个人信息:就读于燕大本科软件project专业 眼下大三;

    本人博客:google搜索“cqs_2012”就可以;

    个人爱好:酷爱数据结构和算法,希望将来从事算法工作为人民作出自己的贡献;

    编程语言:C++ ;

    编程坏境:Windows 7 专业版 x64;

    编程工具:vs2010;

    制图工具:office 2010 powerpoint;

    硬件信息:7G-3 笔记本;


    真言

    假设自己没有完毕任务。不是任务的问题,是自己的问题

    题目

    百练 2818

    思路

    1 暴力法,计算一次。移动一次

    2优化: 计算一次。跟踪一次。再计算,在跟踪;最后在移动

    3再优化:计算须要移动的次数,计算终于结果。然后移动

    ac代码

    #include <iostream>
    #include <string>
    #include <vector>
    using namespace std;
    
    bool my_2818(vector<string> * myvector);
    
    int main()
    {
    	bool sum = true;
    	vector<string> * myvector = new vector<string>;
    	vector<string>::iterator it;
    	while(sum == true)
    		sum = my_2818( myvector );
    	it = myvector->begin();
    	while(it < myvector->end())
    	{
    		cout<<*it<<endl;
    		it++;
    	}
    	system("pause");
    	return 0;	
    }
    
    bool my_2818(vector<string> * myvector)
    {
    	int n;
    	cin>>n;
    	if(n == 0)
    	{
    		return false;
    	}
    	int * data = new int[n];
    	int *length = new int[n];
    	for(int i=0;i<n;i++)
    	{
    		cin>>data[i];
    		length[i] = 0;
    	}
    
    	for(int j,i=0;i<n;i++)
    	{		
    		j = data[i]-1;
    		length[i]++;
    		while(true)
    		{
    			if(j == i)
    				break;
    			j = data[j]-1;
    			length[i]++;
    		}
    	}
    
    	int k;
    	string a;
    	char* b = new char[n];
    	char c;
    	while(true)
    	{
    		cin>>k;
    		if(k == 0)
    			break;
    		for(int i=0;i<n;i++)
    		{
    			b[i] = ' ';
    		}
    		getline(cin,a,'
    ');
    		a=a.substr(1,a.length()-1);
    		while(a.length()<n)
    			a+=' ';
    
    		for(int i=0;i<n;i++)
    		{
    			int j = k % length[i];
    			int m = i;
    			while(j>0)
    			{
    				m = data[m]-1;
    				j--;
    			}
    			b[m] = a[i];
    		}
    		string result="";
    		for(int j=0;j < n;j++)
    			result+=b[j];
    
    		myvector->push_back(result);
    	}
    	myvector->push_back("");
    	return true;
    }
    
    



  • 相关阅读:
    2020牛客暑期多校第三场B-Classical String Problem(字符串移动思维)
    2020牛客暑期多校第四场B-Basic Gcd Problem(思维+数论)
    2020牛客暑期多校第三场E-Two Matchings(规律DP)
    2020牛客暑期多校第三场C-Operation Love(计算几何-顺逆时针的判断)
    odoo高级物流应用:跨厂区生产
    Odoo车辆管理
    安装odoo 9实录
    Odoo 养猪
    【转】结转本年利润的有关分录
    Odoo POS
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/5110931.html
Copyright © 2011-2022 走看看