hdu 1757
来源:互联网 发布:js去掉字符串最后几个 编辑:程序博客网 时间:2024/06/11 21:45
OJ
#include <iostream>#include <cstdio>using namespace std;typedef __int64 LL;struct M{int ma[10][10];M(){memset(ma,0,sizeof(ma));}void in(){memset(ma,0,sizeof(ma));for(int i=0;i<10;i++)scanf("%d",&ma[0][i]);for(int i=1;i<10;i++)ma[i][i-1] = 1;}};M mul(M a,M b,int mod){ M temp;for(int i=0;i<10;i++)for(int j=0;j<10;j++)for(int k = 0;k<10;k++){temp.ma[i][j] += a.ma[i][k]*b.ma[k][j];temp.ma[i][j] %= mod;}return temp;}M mulmod(M a,int n,int mod){ if(n==1) return a;M temp = mulmod(a,n/2,mod);if(n%2) return mul(mul(temp,temp,mod),a,mod);else return mul(temp,temp,mod);}int ends(M a,int mod){int sum = 0;for(int i=9;i>=0;i--){sum += a.ma[0][i]*(9-i);sum %= mod;} return sum;}int main(){int k,m;while(scanf("%d%d",&k,&m)!=EOF){ M xi; xi.in(); if(k<10) printf("%d\n",k%m); else { xi = mulmod(xi,k-9,m);printf("%d\n",ends(xi,m));}}return 0;}
- hdu 1757
- hdu 1757
- HDU 1757
- HDU 1757
- hdu--1757
- (1757)HDU
- hdu 1757
- hdu 1757
- hdu 1757
- hdu 1757(矩阵)
- HDU 1757解题报告
- HDU 1757 矩阵构造
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- http://cdn.ac.nbutoj.com/Problem/view.xhtml?id=1184&&Elaine's Queue
- 内存泄露,缓冲区溢出,堆破坏 的问题
- 《Hadoop The Definitive Guide》ch07 MapReduce Types and Formats
- 大话EM算法
- vs2010下编译Boost 1.46
- hdu 1757
- iphone 3 开发基础教程 4.6按钮编译错误
- Hibernate错误
- hdu 1003 max sum #最大字段和
- java without ide
- unix网络编程-第七章-小结
- dml with lmode=6 ?
- 个人简历
- Linux下用Eclipse编译开源程序