POJ 3012 : A Number from Yanghui Triangle - 快速幂;推公式
来源:互联网 发布:创维网络电视机顶盒 编辑:程序博客网 时间:2024/05/20 13:36
用到快速幂的模版
然后推公式
((1+10^k)^n)%m
3012Accepted700K735MSG++358B
#include <iostream>#include <stdio.h>using namespace std;#define LL long longLL qm(LL a,LL k,LL m){LL re=1,y=a%m;for(;k;k>>=1,y=y*y%m) if(k&1ll) re=y*re%m;return re;}LL n,k,m;int main(){int t;scanf("%d",&t);while(t--){scanf("%lld%lld%lld",&n,&k,&m);printf("%lld\n",qm(qm(10,k,m)+1,n,m));}return 0;}
0 0
- POJ 3012 : A Number from Yanghui Triangle - 快速幂;推公式
- poj 3021 A Number from Yanghui Triangle
- Yanghui Triangle
- yanghui Triangle
- CF 336A(Vasily the Bear and Triangle-推公式)
- HDU_4237_The Rascal Triangle(推公式)
- hdu 3411 推公式+矩阵快速幂
- HDU 4686 (推公式+矩阵快速幂)
- HDU 6198 推公式+矩阵快速幂
- hdu6050 推公式矩阵快速幂
- POJ 3734 推公式
- POJ 2954 Triangle pick公式
- 推公式 codeforces 226A
- hdu 4565 So Easy!(推公式&矩阵快速幂)
- 矩阵乘法+快速幂+序列递推公式
- hdu 2256 Problem of Precision(矩阵快速幂 推公式)
- hdoj 4062 Queuing 【矩阵快速幂优化递推公式】
- HDU 4565So Easy! (矩阵快速幂)(推公式)
- POJ 2159 : Ancient Cipher - 密码模拟
- POJ 3518 : Prime Gap - 素数筛
- POJ 1032 : Paliament - 整数分解
- POJ 1607 /ZOJ 1216 : Deck - 整齐输出
- POJ 3132 / ZOJ 2822 : Sum of Different Primes - 动态规划,01背包,素数筛
- POJ 3012 : A Number from Yanghui Triangle - 快速幂;推公式
- ZOJ 1649 : Rescue - BFS
- ZOJ 2913 : Bus Pass - BFS
- 单行函数测试
- POJ 1465/ ZOJ 1136 : Multiple - BFS,余数判重
- [转] memset用法
- POJ 1523 / ZOJ 1119 - Tarjan算法
- POJ 1144 / ZOJ 1311 : Network - 割点个数
- 初学JQuery的DOM操作