Codeforces 57C Array dp暴力找到规律
主题链接:点击打开链接
的非增量程序首先,计算,
如果不增加的节目数量x, 非减少一些方案是x
答案就是 2*x - n
仅仅需求得x就可以。
能够先写个n3的dp,然后发现规律是 C(n-1, 2*n-1)
然后套个逆元就可以。
#include<iostream>
#include<cstdio>
#include<vector>
#include<string.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll n;
ll Pow(ll x, ll y)
{
ll ans = 1;
while(y)
{
if(y&1) ans = (ans * x) % mod;
y >>= 1;
x = (x*x)%mod;
}
return ans;
}
ll chu(ll x, ll y)
{
return (x * Pow(y, mod-2))%mod;
}
int main(){
ll i, j;
while(cin>>n){
if(n==1){puts("1");continue;}
n -- ;
ll ans = n+2;
ll zi = 2, mu = n+3;
for(i = n+3; i <= 2*n+1; i++)
{
ans *= mu;
ans = chu(ans % mod, zi);
mu++; zi++;
}
ans *= 2; ans -= (n+1);
ans += mod;
cout<<ans%mod<<endl;
}
return 0;
}
版权声明:本文博主原创文章,博客,未经同意不得转载。
Codeforces 57C Array dp暴力找到规律的更多相关文章
- CodeForces 57C Array 组合计数+逆元
题目链接: http://codeforces.com/problemset/problem/57/C 题意: 给你一个数n,表示有n个数的序列,每个数范围为[1,n],叫你求所有非降和非升序列的个数 ...
- Educational Codeforces Round 56 (Rated for Div. 2) F - Vasya and Array dp好题
F - Vasya and Array dp[ i ][ j ] 表示用了前 i 个数字并且最后一个数字是 j 的方案数. dp[ i ][ j ] = sumdp [i - 1 ][ j ], 这样 ...
- HDU 2154 跳舞毯 | DP | 递推 | 规律
Description 由于长期缺乏运动,小黑发现自己的身材臃肿了许多,于是他想健身,更准确地说是减肥. 小黑买来一块圆形的毯子,把它们分成三等分,分别标上A,B,C,称之为“跳舞毯”,他的运动方式是 ...
- LibreOJ #516. 「LibreOJ β Round #2」DP 一般看规律
二次联通门 : LibreOJ #516. 「LibreOJ β Round #2」DP 一般看规律 /* LibreOJ #516. 「LibreOJ β Round #2」DP 一般看规律 set ...
- [LOJ#516]「LibreOJ β Round #2」DP 一般看规律
[LOJ#516]「LibreOJ β Round #2」DP 一般看规律 试题描述 给定一个长度为 \(n\) 的序列 \(a\),一共有 \(m\) 个操作. 每次操作的内容为:给定 \(x,y\ ...
- # E. Mahmoud and Ehab and the xor-MST dp/数学+找规律+xor
E. Mahmoud and Ehab and the xor-MST dp/数学/找规律 题意 给出一个完全图的阶数n(1e18),点由0---n-1编号,边的权则为编号间的异或,问最小生成树是多少 ...
- Codeforces Round #801 (Div. 2) C(规律证明)
Codeforces Round #801 (Div. 2) C(规律证明) 题目链接: 传送门QAQ 题意: 给定一个\(n * m\)的矩阵,矩阵的每个单元的值为1或-1,问从\((1,1)\)开 ...
- Educational Codeforces Round 19 E. Array Queries(暴力)(DP)
传送门 题意 给出n个数,q个询问,每个询问有两个数p,k,询问p+k+a[p]操作几次后超过n 分析 分块处理,在k<sqrt(n)时,用dp,大于sqrt(n)用暴力 trick 代码 #i ...
- Codeforces 1108E2 Array and Segments (Hard version) 差分, 暴力
Codeforces 1108E2 E2. Array and Segments (Hard version) Description: The only difference between eas ...
随机推荐
- 多个viewpager可能产生的问题
由于Fragment的方便性,现在很多人开始大量使用Fragment. 今天使用时遇到各问题,记录下来并分享下. 使用Fragment都会用FragmentActivity ,特别是在用到ViewPa ...
- 【原创】移除RX filters在C118上面
» 作者:LSX » 原创文章版权归作者所有,未经作者同意请保留以下声明. » 本文链接:http://blog.lishixin.net/?p=1318 » 转载请注明来源:LSX·Blog » & ...
- redis在java项目中的使用
在上一篇文章中已经讲了redis的spring配置,这篇将会描述redis在java项目中的使用. redis存储形式都是key-value(键值对),按照存储的内容分为两种,一种是存简单数据,即数字 ...
- windows如何安装scrapy
第一次写博客,有不好的地方请理解! 在linux下安装scrapy几行命令就搞定了,windows就是事多! 话不多说,我们直接进入主题: 1. 下载python.地址 https://www.pyt ...
- web压缩gzip响应
String data = "ggrgrgw4gergergregerge"; byte b[] = data.getBytes(); String gzipValue = req ...
- LintCode-乱序字符串
题目描述: 给出一个字符串数组S,找到其中所有的乱序字符串(Anagram).如果一个字符串是乱序字符串,那么他存在一个字母集合相同,但顺序不同的字符串也在S中. 注意事项 所有的字符串都只包含小写字 ...
- 64位linux下安装oracle10 64位 遇到 :ins_ctx.mk ;ins_emdb.mk
http://blog.csdn.net/bamuta/article/details/10523835 http://www.cnblogs.com/kerrycode/p/3519446.html ...
- 用QComboBox实现tree状结构(QComboBox居然有setView和setModel函数)
实现的效果图如下: #include "mainwindow.h" #include <QApplication> #include <QTreeView> ...
- Ibatis入门基本语法(转) good
Ibatis入门基本语法 一个项目中在写ibatis中的sql语句时,where user_id in (#user_id_list# ), 运行时总是不行,后来上网查了查,才知道这里不该用#,而应该 ...
- hdu1715 大菲波数
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1715 Problem ...