BC Round #76 HDU 5646(数学)
来源:互联网 发布:网络文化传媒公司 编辑:程序博客网 时间:2024/05/17 10:55
// 方法:BC官网有 链接:http://bestcoder.hdu.edu.cn
// main.c// example//// Created by Adam on 15/2/2.// Copyright (c) 2015年 Adam. All rights reserved.////// main.c// example//// Created by Adam on 15/2/2.// Copyright (c) 2015年 Adam. All rights reserved.//#include <algorithm>#include <iostream>#include <string.h>#include <stdlib.h>#include <stdio.h>using namespace std;long long mod=1000000007;int cal(double n, double k){ return (int)((n - (k * k - k)/2) /k);}long long sum(int a, int k){ return 1ll * (a + a + k - 1) * k / 2;}int main(){ int t; scanf("%d", &t); while(t--) { int n, k; scanf("%d%d", &n, &k); if(sum(1,k) > n) { printf("-1\n"); continue; } int pos = cal(n, k); long long int ans = 1; int u = n - sum(pos, k); for(int i = 1; i <= k - u; i++) ans = (ans * (i + pos - 1)) % mod; for(int i = k - u + 1; i <= k; i++) ans = (ans * (i + pos)) % mod; printf("%lld\n", ans); } return 0;}
0 0
- BC Round #76 HDU 5646(数学)
- BC-Round 3 HDU 4908
- Valentine's Day Round(HDU BC比赛)
- hdu 5751 Eades FFT(BC Round 84 E)
- hdu 6020 MG loves apple //bc Round #93 1002
- BC round 50
- BC Round 74
- [Contest] BC Round #79
- HDU 5646 DZY Loves Partition(BC)
- BC round 49 A Untitled
- BestCoder Round #92 第一次BC
- BC-33 hdu 5186
- hdu-5269(bc #44)
- BC,HDU 5719
- HDU 5606 tree BestCoder Round #68 (div.2) [思维]【数学】
- HDU 5776 BestCoder Round #85 sum (数学)
- php中BC math 高精度数学函数
- 数学表达式(expr和bc)
- NetBeans中文乱码解决办法
- 嵌入式linux的系统搭建与配置
- gitlab 的从分支提交过程 --梁泽
- java native方法及JNI实例
- ios关于数据库第三方框架FMDB进阶用法
- BC Round #76 HDU 5646(数学)
- 一致性哈希算法与Java实现
- 欢迎使用CSDN-markdown编辑器
- 【bzoj3675】[Apio2014]序列分割 单调队列+斜率优化
- LeetCode 206 单链表逆置
- 分组交换 的理解
- 图的表示法
- Servlet的特点及运行过程
- Cg入门2:profile和基本数据类型