Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

没有输出0的情况。。。模拟水过。。。

Posted by miubiu at 2018-01-17 18:12:09 on Problem 3087
#include<cstdio>
#include<string>
#include<iostream>

using namespace std;

#define FOR(i, a, b) for(int i = a; i <= b; i++)

const int MAX = 1e2 + 10;

int main()
{
	int test;
	scanf("%d", &test);
	FOR(i, 1, test)
	{
		int len;
		scanf("%d", &len);
		char tmpa[MAX], tmpb[MAX], tmpneed[MAX * 2];
		scanf("%s%s%s", tmpa, tmpb, tmpneed);
		string a = tmpa, b = tmpb, need = tmpneed;
		int ans = 1;
		string tmp;
		for(int j = 0; j < len; j++)
		{
			tmp += b[j];
			tmp	+= a[j]; 
		}
		string org = tmp;
		while(tmp != need)
		{
			ans++;
			a.clear();
			b.clear();
			for(int j = 0; j < len; j++)
			{
				a += tmp[j];
				b += tmp[j + len];
			}
			tmp.clear();
			for(int j = 0; j < len; j++)
			{
				tmp += b[j];
				tmp	+= a[j]; 
			}
			if(tmp == org)
			{
				ans = -1;
				break;
			}
		}
		printf("%d %d\n", i, ans);
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator