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. Spring 中无处不在的 Properties

    转自:https://javadoop.com/post/spring-properties?hmsr=toutiao.io&utm_medium=toutiao.io&utm_sou ...

  2. 配置JSTL

    1.去到官网下载好 4个包 http://tomcat.apache.org/download-taglibs.cgi 2.然后拷贝到 lib目录下 3.导入进去  后面的 C 代替了导入包的名字 4 ...

  3. 可以通过dict[key]获得dict[value]

    dict={key:value,key2:value2} print (dict[key] )    得到的是 dict[value] # 软文预存接口,通过key来预览未保存的软文,联查商品.kol ...

  4. MySQL Connector/Python 接口 (一)

    这里仅介绍 MySQL 官方开发的 Python 接口,参见这里: https://dev.mysql.com/doc/connector-python/en/ Chapter 1 Introduct ...

  5. BZOJ 4415 洛谷 3988 [Shoi2013]发牌

    [题解] 权值线段树.查询当前牌堆顶的牌并且删掉就好了. #include<cstdio> #include<algorithm> #define N 3000010 #def ...

  6. vue 安装+下载

    1. npm init -y [生成package.json文件] 2. 增加 "private": true, 3.npm install 4. npm install vue ...

  7. [luoguP1316] 丢瓶盖(二分答案)

    传送门 二分答案再判断即可 ——代码 #include <cstdio> #include <iostream> #include <algorithm> #def ...

  8. noip模拟赛 enc

    [问题背景]zhx 和他的妹子聊天.[问题描述]考虑一种简单的加密算法.假定所有句子都由小写英文字母构成, 对于每一个字母, 我们将它唯一地映射到另一个字母. 例如考虑映射规则:a->b, b- ...

  9. codeforces 371D

    #include<stdio.h> #define N 210000 struct node { int x,next; __int64 count,vec; }pre[N]; int n ...

  10. 洛谷—— P2176 [USACO14FEB]路障Roadblock

    https://www.luogu.org/problem/show?pid=2176 题目描述 每天早晨,FJ从家中穿过农场走到牛棚.农场由 N 块农田组成,农田通过 M 条双向道路连接,每条路有一 ...