hdu 4602 Partition(计数)
来源:互联网 发布:ubuntu 14.04u盘镜像 编辑:程序博客网 时间:2024/06/05 20:20
题目链接:hdu 4602 Partition
代码
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int mod = 1e9 + 7;int N, K;long long pow_mod(long long x, int n) { if (n < 0) return 0; long long ret = 1; while (n) { if (n&1) ret = ret * x % mod; x = x * x % mod; n >>= 1; } return ret;}int main () { int cas; scanf("%d", &cas); while (cas--) { scanf("%d%d", &N, &K); if (N == K) { printf("1\n"); continue; } int ans = pow_mod(2, N-K); ans = (ans + pow_mod(2, N-K-2) * (N-K-1)) % mod; printf("%d\n", ans); } return 0;}
0 0
- hdu 4602 Partition(计数)
- hdu - 4602 - Partition(快速幂)
- hdu 4602 Partition (概率方法)
- HDU 4602 Partition(快速幂)
- HDU 4602 Partition (快速幂+思维)
- hdu - 4602 《Partition》
- HDU 4602 Partition
- HDU 4602 Partition
- hdu-4602-Partition
- hdu 4602 Partition
- HDU 4602 Partition
- hdu 4602 Partition
- hdu(4602) Partition
- hdu 4602 Partition
- HDU 4602 Partition
- hdu 4602 Partition
- HDU 4602 Partition
- HDU 4602 Partition
- leetcode之路051 N-Queens
- 内部类序列化出错
- CSS和SVG中的剪切——clip-path属性和<clipPath>元素
- 指针
- MRC环境 引用计数器
- hdu 4602 Partition(计数)
- 解决thinkPHP出现_STORAGE_WRITE_ERROR_:./Runtime/Cache/Install/xxx.php的解决
- 嵌入式工程师----我来了
- 反转单链表 (三种方法整理)
- LeetCode-Roman to Integer
- 传递正能量-献给默默追梦的人
- hdu 1019 Least Common Multiple【gcd】
- C语言中的变量
- 软件工程第二章作业