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 |
Re:一个简单巧妙的解法 469B 32msIn Reply To:一个简单巧妙的解法 469B 32ms Posted by:416221843 at 2016-08-03 15:53:34 > 学习于某大神的博客 > 首先 把某开关同行同列的所有开关动1遍 结果是只有该开关变化 其他开关不变化 > 策略就是如果1个开关是关的 就把他同行同列的所有开关动1遍 而一个开关操作偶数次相当于没有操作 只要模拟出上述过程统计一下操作奇数次的开关有多少就好 > #include<stdio.h> > #include<string.h> > int main() > {bool b[4][4];int i, j, k, a = 0; > char q; memset(b, 0, sizeof(b)); > for (i = 0; i < 4; i++) > {for (j = 0; j < 4; j++) > {scanf("%c", &q); if (q == '+') { > for (k = 0; k < 4; k++) b[i][k]=!b[i][k], b[k][j]=!b[k][j]; > b[i][j]=!b[i][j];} > }getchar();} > for (i = 0; i < 4; i++) > for (j = 0; j < 4; j++) > if (b[i][j]) a++; > printf("%d\n", a); > for (i = 0; i < 4; i++) > for (j = 0; j < 4; j++) > if (b[i][j]) printf("%d %d\n", i + 1, j + 1);} Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator