Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
新生手机党求助,给点提示哪错了可以吗?或者来一组测试数据,别太多组,手机编译器目前运行时无法粘贴。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator