HDU - 233 Matrix】的更多相关文章

原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=5015 解题思路:一看到题目,感觉是杨辉三角形,然后用组合数学做,不过没想出来怎么做,后来看数据+递推思想,感觉可能是矩阵快速幂,可惜一直不知道a*10+3的 +3怎么处理,果然还是图样图森破啊!如果矩阵能搞出来的话,后面的就简单了,真可惜一直到比赛结束也没想出来,看来这种矩阵的题目做的太少了,真后悔线性代数没有认真学.. 今天晚上又想了一会,完全可以把+3那个放到新的一阶矩阵上,值始终等于3,那么对…
233 Matrix Time Limit:5000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Description In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the quest…
233 Matrix In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. In the first line, it would be 233, 2333…
先贴四份矩阵快速幂的模板:http://www.cnblogs.com/shangyu/p/3620803.html http://www.cppblog.com/acronix/archive/2010/08/23/124470.aspx?opt=admin http://www.cnblogs.com/vongang/archive/2012/04/01/2429015.html http://www.cnblogs.com/yan-boy/archive/2012/11/29/279529…
233 Matrix Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 749    Accepted Submission(s): 453 Problem Description In our daily life we often use 233 to express our feelings. Actually, we may s…
In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. In the first line, it would be 233, 2333, 23333...…
233 Matrix Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1190    Accepted Submission(s): 700 Problem Description In our daily life we often use 233 to express our feelings. Actually, we may s…
[HDU5015]233 Matrix 试题描述 In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. In the first line, it woul…
HDU5015 233 Matrix(矩阵高速幂) 题目链接 题目大意: 给出n∗m矩阵,给出第一行a01, a02, a03 ...a0m (各自是233, 2333, 23333...), 再给定第一列a10, a10, a10, a10,...an0.矩阵中的每一个元素等于左边的加上上面的,求出anm. 解题思路: 先要依据矩阵元素的特征得出相乘的矩阵T, 然后就是求这个矩阵T的m次幂(这里就能够用矩阵高速幂),最后再和给定的第一列所形成的矩阵相乘,就能得到anm. 求矩阵T请參考 代码:…
In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. In the first line, it would be 233, 2333, 23333...…
Description In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. In the first line, it would be 233, 233…
题目链接:https://vjudge.net/problem/HDU-5015 233 Matrix Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2805    Accepted Submission(s): 1611 Problem Description In our daily life we often use 233 t…
HDU 4920 Matrix multiplication 题目链接 题意:给定两个矩阵,求这两个矩阵相乘mod 3 思路:没什么好的想法,就把0的位置不考虑.结果就过了.然后看了官方题解,上面是用了bitset这个东西,能够用来存大的二进制数,那么对于行列相乘.事实上就几种情况,遇到0都是0了,1 1得1,2 1,1 2得2,2 2得1.所以仅仅要存下行列1和2存不存在分别表示的二进制数.然后取且bitcount一下的个数,就能够计算出对应的数值了 代码: 暴力: #include <cst…
In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. In the first line, it would be 233, 2333, 23333...…
HDU 2686 Matrix 题目链接 3376 Matrix Again 题目链接 题意:这两题是一样的,仅仅是数据范围不一样,都是一个矩阵,从左上角走到右下角在从右下角走到左上角能得到最大价值 思路:拆点.建图,然后跑费用流就可以,只是HDU3376这题,极限情况是300W条边,然后卡时间过了2333 代码: #include <cstdio> #include <cstring> #include <vector> #include <queue>…
233 Matrix 有一\(n\times m\)的矩阵\(\{a\}\),定义\(a[0][0]=0,a[0][1]=233,a[0][2]=2333,a[0][3]=23333...\),然后给出\(a[1][0],a[2][0],...,a[n][0]\),未给出或定义的位置满足\(a[i][j]=a[i-1][j]+a[i][j-1]\),询问\(a[n][m]\)的值\(mod\ 10000007\),\(n ≤ 10,m ≤ 10^9\). 解 显然对于第0行,我们有转移方程\(a…
http://acm.hdu.edu.cn/showproblem.php?pid=5015 由于是个二维的递推式,当时没有想到能够这样构造矩阵.从列上看,当前这一列都是由前一列递推得到.依据这一点来构造矩阵.令b[i]代表第i列,是一个(n+2)*1的矩阵,即b[1] = [1,233......],之所以在加了两行,是要从前一个矩阵b[i-1]得到b[i]中的第二个数2333...,再构造一个转换矩阵a,它是一个(n+2)*(n+2)的矩阵,那么a^(m-1) * b就是第m列. /* a矩…
题意:给出矩阵的第0行(233,2333,23333,...)和第0列a1,a2,...an(n<=10,m<=10^9),给出式子: A[i][j] = A[i-1][j] + A[i][j-1],要求A[n][m]. 解法:看到n<=10和m<=10^9 应该对矩阵有些想法,现在我们假设要求A[a][b],则A[a][b] = A[a][b-1] + A[a-1][b] = A[a][b-1] + A[a-1][b-1] + A[a-2][b] = ... 这样相当于右图:,红…
题意:给定一个矩阵的第0列的第1到n个数,第一行第1个数开始每个数分别为233, 2333........,求第n行的第m个数. 分析: 其实也没那么难,自己想了半天还没往对的方向想,m最大1e9,应该立即想到要用到快速幂,关键在于递推矩阵. 递推矩阵的作用是依次算出每一列,第1列第一个数233是前一列的23*10+3,将前一列增加一个元素[3, 23, a1, a2,....an],然后第一列第一个数为3,对应向量[1, 0, 0, 0.....0],233对应向量[1, 10, 0, ...…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5015 [算法] 矩阵乘法 [代码] #include<bits/stdc++.h> using namespace std; ; int i,j,n,m,ans; ],val[]; struct Matrix { ][]; } b; inline void multipy(Matrix &a,Matrix b) { int i,j,k; Matrix res; memset(res.m…
矩阵快速幂 按列递推 #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <cstring> #define ll long long using namespace std; const int MOD = 10000007; int n, m; struct Matrix {…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2686 Yifenfei very like play a number game in the n*n Matrix. A positive integer number is put in each area of the Matrix.Every time yifenfei should to do is that choose a detour which frome the top left…
matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5569 Description Given a matrix with n rows and m columns ( n+m is an odd number ), at first , you begin with the number at top-left corner (1,1) and you wa…
各种TEL,233啊.没想到是处理掉0的情况就能够过啊.一直以为会有极端数据.没想到居然是这种啊..在网上看到了一个AC的奇妙的代码,经典的矩阵乘法,仅仅只是把最内层的枚举,移到外面就过了啊...有点不理解啊,复杂度不是一样的吗.. Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 640 …
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2119 Matrix Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2205    Accepted Submission(s): 975 Problem Description Give you a matrix(only contains…
Matrix 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5671 Description There is a matrix M that has n rows and m columns (1≤n≤1000,1≤m≤1000).Then we perform q(1≤q≤100,000) operations: 1 x y: Swap row x and row y (1≤x,y≤n); 2 x y: Swap column x and c…
Matrix Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3095    Accepted Submission(s): 1428 Problem Description Give you a matrix(only contains 0 or 1),every time you can select a row or a colu…
Matrix Swapping II Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1430    Accepted Submission(s): 950 Problem Description Given an N * M matrix with each entry equal to 0 or 1. We can find som…
Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description Given two matrices A and B of size n×n, find the product of them. bobo hates big integers. So you are only asked to find t…
要注意取出来的时候 先取出q的是后面那个矩阵 后取出p的是前面的矩阵 所以是判断 p.a == q.b #include <iostream> #include <stack> #include <cstring> #include <cstdio> using namespace std; struct Matrix{ int a,b; Matrix(,):a(aa),b(bb){} }m[]; stack<Matrix>s; int main…