http://codeforces.com/problemset/problem/405/C

题意:

给出一个n*n的矩阵,有q个操作,输入3时,输出A ,A等于第i行乘以第i列的对应元素的和(mod2),输入1 x,表示将第x行的元素翻转(即0变成1,1变成0),输入2 x,表示将第x列的元素翻转.

思路:

根据A的计算方式可知A的最终结果只由左对角线上的元素将决定,如果左对角线上的元素为1的个数有奇数个(可通过异或计算),则A=1,否则A=0。翻转的时候每翻转一行或一列,都会改变对角线的元素,故结果应异或上1.

 #include <stdio.h>
#include <string.h>
const int N=;
int a[N][N]; int main()
{
int n;
scanf("%d",&n);
int A = ;
for (int i = ; i <= n; i++)
{
for (int j = ; j <= n; j++)
{
scanf("%d",&a[i][j]);
if (i==j) A^=a[i][j];
}
}
int q,x;
scanf("%d",&q);
while(q--)
{
scanf("%d",&x);
if (x==)
printf("%d",A);
else
{
scanf("%d",&x);
A^=;
}
}
return ;
}

C. Unusual Product(cf)的更多相关文章

  1. CF 405C Unusual Product(想法题)

    题目链接: 传送门 Domino Effect time limit per test:1 second     memory limit per test:256 megabytes Descrip ...

  2. codeforces Unusual Product

    题意:给你n*n的矩阵,里面是1或0,然后q次询问,如果操作数为1,那么就把x行的数0变成1,1变成0:如果操作数为2,那么在x列上的数0变成1,1变成0:如果是3,输出: 思路:在求的时候,对角线上 ...

  3. cf div2 238 c

    C. Unusual Product time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  4. CodeForces - 405C

    Unusual Product Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Sub ...

  5. Codeforces Round #238 (Div. 1)

    感觉这场题目有种似曾相识感觉,C题还没看,日后补上.一定要坚持做下去. A Unusual Product 题意: 给定一个n*n的01矩阵,3种操作, 1 i 将第i行翻转 2 i 将第i列翻转 3 ...

  6. 获取配置文件信息——configparser

    配置文件host.int格式如下: [host]product=xxxxxxxxxxtest=xxxxxxxxxx python 3.x代码如下: import os,configparser def ...

  7. 基于python2+selenium3+pytest4的UI自动化框架

    环境:Python2.7.10, selenium3.141.0, pytest4.6.6, pytest-html1.22.0, Windows-7-6.1.7601-SP1 特点:- 二次封装了s ...

  8. cf 1182 E - Product Oriented Recurrence

    当时脑残了, 不会写矩阵快速幂中更改的系数, 其实把他扔到矩阵里同时递推就好了 #include<cstdio> #include<algorithm> #include< ...

  9. CF 900D Unusual Sequences

    题目链接 \(Description\) 给定\(x,y\),求有多少个数列满足\(gcd(a_i)=x且\sum a_i=y\).答案对\(10^9+7\)取模. \(1≤x,y≤10^9\) \( ...

随机推荐

  1. Gym - 101670H Go Northwest!(CTU Open Contest 2017 思维题+map)

    题目: Go Northwest! is a game usually played in the park main hall when occasional rainy weather disco ...

  2. bootstrap-table使用笔记

    服务端分页: //html <div class="container-fluid"> <div style="margin-top:1em" ...

  3. LINUX驱动、系统底层

    就业模拟测试题-LINUX驱动.系统底层工程师职位 本试卷从考试酷examcoo网站导出,文件格式为mht,请用WORD/WPS打开,并另存为doc/docx格式后再使用 试卷编号:143921试卷录 ...

  4. #if 0的意义和好处

    在调试中经常遇到,写好的程序,需要调试相反的两方面,如:有两款单片机的程序,分别对应着不同的硬件引脚,我们把代码都写上了,但是不能同时让他们起效,通常的办法是/**/屏蔽一些段落,但是调试起来很麻烦. ...

  5. python爬取数据保存到Excel中

    # -*- conding:utf-8 -*- # 1.两页的内容 # 2.抓取每页title和URL # 3.根据title创建文件,发送URL请求,提取数据 import requests fro ...

  6. [24点计算器][C++版本]无聊拿去玩

    特性:数字数量.目标答案不限,当然数据大了会很慢... 基本可以去除所有本质相同的表达式...至少能等出结果的数据规模可以.. 安卓:http://yun.baidu.com/s/1slCGILn 程 ...

  7. PatentTips - Hamming distance comparison

    BACKGROUND INFORMATION In a typical data processing environment, data may be transmitted in multiple ...

  8. 试来试去,WIN下最简单的WIN API开发工具,Pelles C就好啦

    昨晚试过N个,不是太大,就是不容易和WIN API集成. 今早一试就灵了个.... Pelles C. Pelles C是一款windows下的C IDE,支持调试,且为免费.它有一个高效率的链接器, ...

  9. C. Painting Fence 分治

    memory limit per test 512 megabytes input standard input output standard output Bizon the Champion i ...

  10. MySQL出现:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet sent to the server was 0 ms ago.

    1.首先检查生产环境的机器是否ping的通和telnet的通数据库 2.排查数据库连接的参数 3.看数据量是否很大 参考: http://blog.csdn.net/sclxf/article/det ...