[HDU2256]Problem of Precision
来源:互联网 发布:中国网络作家 编辑:程序博客网 时间:2024/05/06 05:48
题目大意:
#include<iostream>#include<cmath>#include<cstdio>#include<cstring>#include<algorithm>#include<map>using namespace std;struct Matrix{ int element[2][2];};int n, kase;Matrix a, b;Matrix MUL(Matrix a, Matrix b){ Matrix c; for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) { c.element[i][j] = 0; for (int k = 0; k < 2; k++) c.element[i][j] = (c.element[i][j] + a.element[i][k] * b.element[k][j]) % 1024; } return c;}void POW(int k){ if (k != 1) POW(k / 2); else return; a = MUL(a, a); if (k % 2 == 1) a = MUL(a, b);}int main(){ cin >> kase; while (kase--) { cin >> n; b.element[0][0] = 5; b.element[0][1] = 2; b.element[1][0] = 12; b.element[1][1] = 5; a = b; if (n > 1) POW(n - 1); b.element[0][0] = 5; b.element[0][1] = 2; b.element[1][0] = 0; b.element[1][1] = 0; if (n > 1) a = MUL(b, a); else a = b; cout << (2 * a.element[0][0] + 1023) % 1024 << endl; }}
- Problem of Precision hdu2256
- [HDU2256]Problem of Precision
- [矩阵快速幂]hdu2256 Problem of Precision
- HDU2256-Problem of Precision(矩阵构造+快速幂)
- HDU2256 Problem of Precision 构造递推式+矩阵快速幂
- hdu2256:Problem of Precision(矩阵快速幂+共轭)
- HDOJ 2256 - Problem of Precision
- Hdu 2256 Problem of Precision
- hdu 2256 Problem of Precision
- hdu 2256 Problem of Precision
- HDU - 2256 Problem of Precision
- hdu 2256-Problem of Precision
- hdoj 2256 Problem of Precision
- HDU 2256 Problem of Precision
- HDOJ 2256 Problem of Precision
- HDU 2256 Problem of Precision
- HDU 2256 Problem of Precision
- hdu 2256 Problem of Precision 矩阵
- 指令集及流水线基本概念
- 一些操作系统笔试、面试题
- Https + OPENSSL
- sqlserver的statistics操作语句
- [LeetCode]Gray Code
- [HDU2256]Problem of Precision
- N皇后问题
- UITbaleView滚动到最后一行
- [LeetCode]Implement strStr()
- 可以预见的未来(连续剧2)
- js封装,复用,放大效果
- php 初学头疼问题之:php.ini
- [LeetCode]Insert Interval
- 关于PowerDesigner15不能从PDM图生成MS SQL2005/2008外键约束的问题