poj 2115 Matrix】的更多相关文章

题意: 给出一个矩阵,有两种操作: 1.翻转给定的子矩阵: 2.查询a[i][j]的值. 思路: 树状数组是从小到大更新的. 这个题用二维树状数组可以解决,假设是一维树状数组, 0 0 0 0 0 0 我们把第三个到第四个翻转,变成 0 0 1 1 -1 0 sum[1] = 0,sum[2] = 0,sum[3] = 1,sum[4] = 1,sum[5] = 0,sum[6] = 0 所以类似一维的bit,但是要用到容斥原理,多减的要加回来. 代码: #include <stdio.h>…
题目地址:POJ 2115 水题. . 公式非常好推.最直接的公式就是a+n*c==b+m*2^k.然后能够变形为模线性方程的样子,就是 n*c+m*2^k==b-a.即求n*c==(b-a)mod(2^k)的最小解.(真搞不懂为什么训练的时候好多人把青蛙的约会都给做出来了,这题却一直做不出来.. . . . 这两道不都是推公式然后变形吗. .... ) 代码例如以下: #include <iostream> #include <cstdio> #include <strin…
题目链接[http://poj.org/problem?id=2155] /* poj 2155 Matrix 题意:矩阵加减,单点求和 二维线段树,矩阵加减,单点求和. */ using namespace std; const int INF = 0x3f3f3f3f; ; int N, Q; struct Nodey { int l, r; int val; }; int locx[MAXN], locy[MAXN]; struct Nodex { int l, r; Nodey sty[…
POJ 2115:http://poj.org/problem?id=2115 思路 设循环T次 则要满足A≡(B+CT)(mod 2k) 可得 A=B+CT+m*2k 移项得C*T+2k*m=B-A (因为要满足B大于A)即是Exgcd的标准式子了 代码 #include<iostream> #include<cstdio> using namespace std; #define ll long long ll A,B,C,T,k; int gcd(ll a,ll b) { i…
poj 1575  Tr A 主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1575 题目大意:A为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973. 数据的第一行是一个T,表示有T组数据. 每组数据的第一行有n(2 <= n <= 10)和k(2 <= k < 10^9)两个数据.接下来有n行,每行有n个数据,每一个数据的范围是[0,9].表示方阵A的内容. 一个矩阵高速幂的裸题. 题解: #…
二维树状数组....                          Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 15575   Accepted: 5854 Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th colu…
Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 17880   Accepted: 6709 Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1…
Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 17226   Accepted: 6461 Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1…
Description Given a N × N matrix A, whose element × i + j2 - × j + i × j, you are to find the M-th smallest element in the matrix. Input The first line of input is the number of test case. For each test ≤ N ≤ ,) and M( ≤ M ≤ N × N). There is a blank…
http://poj.org/problem?id=2155 Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 18143   Accepted: 6813 Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. I…