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

新生手机党求助,给点提示哪错了可以吗?或者来一组测试数据,别太多组,手机编译器目前运行时无法粘贴。

Posted by 120302508 at 2012-12-06 19:01:39 on Problem 1832
#include<stdio.h>
#include<string.h>
int a[128], b[128];
char result[128];

void mul2()
{
	int i, t = 0;
	for (i = 126; i >= 0; i--)
	{
		result[i] = result[i] * 2 - '0' + t;
		if (result[i] > '9')
		{
			result[i] -= 10;
			t = 1;
		}
		else
			t = 0;
	}
}

int main()
{
	int n, m, i, j;
	scanf("%d", &n);
	while (n--)
	{
		scanf("%d", &m);
		for (i = m - 1; i >= 0; i--)
			scanf("%d", &a[i]);
		for (i = m - 1; i >= 0; i--)
			scanf("%d", &b[i]);
		for (i = 0; i < m; i++)
			a[i] ^= b[i];
		for (i = 1; i < m; i++)
		{
			for (j = 0; j < i; j++)
				a[j] ^= a[i];
		}
		for (i = 0; i < 127; i++)
			result[i] = '0';
		result[127] = 0;
		for (i = m - 1; i >= 0; i--)
		{
			if (a[i])
				result[126]++;
			if (i)
				mul2();
		}
		for (i = 0; !(result[i] - '0') && (i < 127); i++);
		puts(result + i);
	}
	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