FZU 2238 Daxia & Wzc's problem
公式。
$a×C_{m + i - 1}^m + d×C_{m + i - 1}^{m + 1}$。
推导过程可以看http://blog.csdn.net/queuelovestack/article/details/52260127
- #pragma comment(linker, "/STACK:1024000000,1024000000")
- #include<cstdio>
- #include<cstring>
- #include<cmath>
- #include<algorithm>
- #include<vector>
- #include<map>
- #include<set>
- #include<queue>
- #include<stack>
- #include<iostream>
- using namespace std;
- typedef long long LL;
- const double pi=acos(-1.0),eps=1e-;
- void File()
- {
- freopen("D:\\in.txt","r",stdin);
- freopen("D:\\out.txt","w",stdout);
- }
- template <class T>
- inline void read(T &x)
- {
- char c = getchar(); x = ;while(!isdigit(c)) c = getchar();
- while(isdigit(c)) { x = x * + c - ''; c = getchar(); }
- }
- LL a,d,i,m,p;
- LL quick_mod(LL a, LL b)
- {
- LL ans = ;
- a %= p;
- while(b)
- {
- if(b & )
- {
- ans = ans * a % p;
- b--;
- }
- b >>= ;
- a = a * a % p;
- }
- return ans;
- }
- LL C(LL n, LL m)
- {
- if(m > n) return ;
- LL ans = ;
- for(int i=; i<=m; i++)
- {
- LL a = (n + i - m) % p;
- LL b = i % p;
- ans = ans * (a * quick_mod(b, p-) % p) % p;
- }
- return ans;
- }
- LL Lucas(LL n, LL m)
- {
- if(m == ) return ;
- return C(n % p, m % p) * Lucas(n / p, m / p) % p;
- }
- int main()
- {
- while(~scanf("%I64d%I64d%I64d%I64d", &a,&d,&m, &i))
- {
- p=;
- printf("%I64d\n", (a*Lucas(m+i-,m)+d*Lucas(m+i-,m+))%p);
- }
- return ;
- }
FZU 2238 Daxia & Wzc's problem的更多相关文章
- FZU Problem 2238 Daxia & Wzc's problem
Daxia在2016年5月期间去瑞士度蜜月,顺便拜访了Wzc,Wzc给他出了一个问题: Wzc给Daxia等差数列A(0),告诉Daxia首项a和公差d; 首先让Daxia求出数列A(0)前n项和,得 ...
- 【数论】FOJ 2238 Daxia & Wzc's problem
题目链接: http://acm.fzu.edu.cn/problem.php?pid=2238 题目大意: 已知等差数列A(0)的首项a和公差d,求出数列A(0)前n项和,得到新数列A(1);以此类 ...
- Problem 2238 Daxia & Wzc's problem 1627 瞬间移动
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1627 http://acm.fzu.edu.cn/problem.php ...
- FZU 8月有奖月赛A Daxia & Wzc's problem (Lucas)
Problem A Daxia & Wzc's problem Accept: 42 Submit: 228Time Limit: 1000 mSec Memory Limit : ...
- FZU 2240 Daxia & Suneast's problem
博弈,$SG$函数,规律,线段树. 这个问题套路很明显,先找求出$SG$函数值是多少,然后异或起来,如果是$0$就后手赢,否则先手赢.修改操作和区间查询的话可以用线段树维护一下区间异或和. 数据那么大 ...
- FZU 2224 An exciting GCD problem(GCD种类预处理+树状数组维护)同hdu5869
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2224 同hdu5869 //#pragma comment(linker, "/STACK:1024 ...
- FZU - 2038 -E - Another Postman Problem (思维+递归+回溯)
Chinese Postman Problem is a very famous hard problem in graph theory. The problem is to find a shor ...
- FZU 2243 Daxia like uber
枚举,最短路. 求出5个点出发的最短路,然后枚举一下这些点之间走的顺序. #pragma comment(linker, "/STACK:1024000000,1024000000" ...
- HITtrainning20140417题解
题目列表: ID Origin Title 10 / 15 Problem A FZU 2152 文件系统 0 / 16 Problem B FZU 2153 A simple geome ...
随机推荐
- Spectral Clustering
谱聚类算法(Spectral Clustering)优化与扩展 谱聚类(Spectral Clustering, SC)在前面的博文中已经详述,是一种基于图论的聚类方法,简单形象且理论基础充分,在 ...
- Stimulsoft.Report.net报表简单实用
1 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System. ...
- URL 调度器(URL dispatcher)
URL 调度器(URL dispatcher) 在刚开始接触 django 的时候, 我们尝试着从各种入门文档中创建一个自己的 django 项目, 需要在 mysite.urls.py 中配置 UR ...
- 基于 Aliexpress API 的小程序 : 批量 Copy 产品到不同的店铺
第一个基于 Aliexpress API 的小程序 : 批量 Copy 产品到不同的店铺 还没来得及用 API 重写软件, 先写个小程序来缓解一下手工压力: 批量Copy 产品到不同的店铺. 开网店 ...
- 简单的mvc之一:简单的开始
mvc学习到现在,相对所学到的一系列的知识做一个总结,于是就有了这个标题—简单的mvc.文如名,写的是简单的mvc的知识,目标群也不言而喻.这一篇来个简单的开始,从头建立一个web项目,比如hello ...
- [转载]linux下编译php中configure参数具体含义
编译N次了 原来这么回事 原文地址:linux下编译php中configure参数具体含义作者:捷心特 php编译参数的含义 ./configure –prefix=/usr/local/php ...
- sql 数据库还原脚本 (kill链接+独占
在开发过程中经常会碰到数据库还原,要是sql 连接没完全释放掉,那么还原就会受到阻碍.此脚本就是为了解决这个问题. USE [master] GO /****** Object: StoredProc ...
- 数据结构中的棧在C#中的实现
数据结构中的棧在C#中的实现 一.大致学习 棧是一种面向表的数据结构,棧中的数据只能在标的某一短进行添加和删除操作,是一种典型的(LIFO)数据结构. 现实生活中的理解:自助餐厅的盘子堆,人们总是从顶 ...
- 关于C++中Object所占内存空间探索1
关于C++中Object所占内存空间探索(一) 有如下问题: 1. 一个空类, class X{ }; 2.类中含有数据成员(Data Member), class X { public: //Fun ...
- MacOSX64位机器上gcc编译32位x264静态库
x264最新包地址:http://www.videolan.org/developers/x264.html 编译命令: ./configure --enable-static --host=i386 ...