HDU 4565 So Easy!
来源:互联网 发布:mac上怎么做u盘启动盘 编辑:程序博客网 时间:2024/06/02 07:28
我不是看这里的,你们不要质疑我。
#include <iostream>#include <cstdio>#include <algorithm>#include <cmath>typedef __int64 LL;using namespace std;struct matrix{ LL a[2][2];}origin,res;LL A,B,M;matrix multiply(matrix x,matrix y){ matrix temp; memset(temp.a,0,sizeof(temp.a)); for(int i=0;i<2;i++) { for(int j=0;j<2;j++) { for(int k=0;k<2;k++) { temp.a[i][j]+=x.a[i][k]*y.a[k][j]; temp.a[i][j]=(temp.a[i][j]+M)%M; } } } return temp;}void matmod(LL n){ while(n) { if(n&1) res=multiply(res,origin); n>>=1; origin=multiply(origin,origin); } LL C1=2*A; LL C0=2; //printf("c1 = %d\n",C1); printf("%I64d\n",((res.a[0][0]*C1+res.a[0][1]*C0)+M)%M);}int main(){ LL N; while(scanf("%I64d %I64d %I64d %I64d",&A,&B,&N,&M)!=EOF) { origin.a[0][0]=2*A; origin.a[0][1]=(-(A*A-B)); origin.a[1][0]=1; origin.a[1][1]=0; res.a[0][0]=1; res.a[0][1]=0; res.a[1][0]=0; res.a[1][1]=1; matmod(N-1); } return 0;}
- HDU 4565 So Easy!
- hdu 4565 So Easy!
- HDU 4565 So Easy!
- hdu 4565 So Easy!
- HDU 4565 So Easy!
- hdu 4565 So Easy!
- HDU 4565 So Easy!
- hdu 4565 So Easy!
- hdu 4565So Easy!
- hdu 4565 So Easy!
- HDU 4565 So Easy!
- HDU 4565 So Easy!
- hdu 4565 So Easy!
- HDU 4565 SO easy!
- HDU 4565 So Easy!
- hdu 4565 So Easy!
- HDU 4565 So Easy!
- HDU 4565 So Easy!
- Tiny6410_buttons.c 按键驱动程序
- hdu 1505 hdu 1506 hdu 2870 综合解答
- 对一组字符串排序,使子串总在父串之后
- hdu2870之DP
- VMware_VCP5.0 虚拟化认证原厂培训中文教材 PPT
- HDU 4565 So Easy!
- Codeforces Round #188 (Div. 1) / 317A Perfect Pair(数学&优化)
- poj-1200 Crazy Search
- Wing IDE 4.1使用笔记一修正一下框框字体显示不了中文
- HDOJ 1789
- struts2-常用功能
- Java String.Format() 方法及参数说明
- struts2的验证框架
- SDJZU Digital Roots