CF15E Triangles
思路
有四种方法,L,R,L->R,只走上面的小三角形
然后组合方案数\(2f^2+8f+10\)
然后求f,递推一下就好啦(其实是太麻烦了)
时间和空间复杂度都是\(O(n)\)
代码
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
const int MOD = 1000000009;
int n,f[1000100],g[1000100],times=1;
int t(int x){
if(x%2)
return x/2;
return 0;
}
signed main(){
scanf("%lld",&n);
f[0]=0;
f[1]=2;
g[1]=4;
for(int i=2;i<=n;i++){
g[i]=(1LL*g[i-1]*2+4)%MOD;
// printf("g[%d]=%d\n",i,g[i]);
}
for(int i=2;i<=n-2;i++){
f[i]=1LL*(2*times%MOD+f[i-1]+2LL*g[t(i)]*times%MOD)%MOD;
if(i%2)
times=1LL*times*(g[t(i)]+1)%MOD;
// printf("f[%d]=%d\n",i,f[i]);
}
printf("%lld\n",(1LL*2*f[n-2]*f[n-2]%MOD+1LL*8*f[n-2]%MOD+10)%MOD);
return 0;
}
CF15E Triangles的更多相关文章
- Count the number of possible triangles
From: http://www.geeksforgeeks.org/find-number-of-triangles-possible/ Given an unsorted array of pos ...
- [ACM_搜索] Triangles(POJ1471,简单搜索,注意细节)
Description It is always very nice to have little brothers or sisters. You can tease them, lock them ...
- acdream.Triangles(数学推导)
Triangles Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit Stat ...
- UVA 12651 Triangles
You will be given N points on a circle. You must write a program to determine how many distinctequil ...
- Codeforces Gym 100015F Fighting for Triangles 状压DP
Fighting for Triangles 题目连接: http://codeforces.com/gym/100015/attachments Description Andy and Ralph ...
- Codeforces Round #309 (Div. 1) C. Love Triangles dfs
C. Love Triangles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/553/pro ...
- Codeforces Round #308 (Div. 2) D. Vanya and Triangles 水题
D. Vanya and Triangles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55 ...
- Project Euler 94:Almost equilateral triangles 几乎等边的三角形
Almost equilateral triangles It is easily proved that no equilateral triangle exists with integral l ...
- Project Euler 91:Right triangles with integer coordinates 格点直角三角形
Right triangles with integer coordinates The points P (x1, y1) and Q (x2, y2) are plotted at integer ...
随机推荐
- Qt——树的搜索实现源码
一.使用QTreeWidget 头文件: /************************************************************************ 树的搜索类 ...
- innodb事务锁的一些常见数据结构
lock_sys_t 整个innodb的锁系统管理结构体,定义在lock0lock.h中.在lock0lock.cc中有一个lock_sys_t的全局指针lock_sys, 由lock_sys_cre ...
- mui mui-control-item获得选中的标签
function getActiveControl() { var segmentedControl = document.getElementById("top-scroll") ...
- HDU6739 Invoker 【dp】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6739 借鉴了这个网址的题解:https://blog.csdn.net/qq_41785863/art ...
- 什么是文件存储NAS
阿里云文件存储(Network Attached Storage,简称 NAS)是面向阿里云 ECS 实例.E-HPC 和容器服务等计算节点的文件存储服务. 定义 阿里云文件存储 NAS 是一个可共享 ...
- 【LOJ】#3096. 「SNOI2019」数论
LOJ#3096. 「SNOI2019」数论 如果\(P > Q\)我们把\(P\)和\(Q\)换一下,现在默认\(P < Q\) 这个时候每个合法的\(a_i\)都可以直接落到\(Q\) ...
- 2.3负载均衡:Ribbon
基于上一篇文章的工程,启动eureka-server 工程:启动service-hi工程,它的端口为8765:将service-hi的配置文件的端口改为8763,并启动,这时你会发现:service- ...
- cdoj 574 High-level ancients dfs序+线段树 每个点所加权值不同
High-level ancients Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/s ...
- (转)如何真正实现由文档驱动的API设计?
前言 本文主要介绍了一种新的开发思路:通过反转开发顺序,直接从API文档中阅读代码.作者认为通过这种开发方式,你可以更清楚地知道文档表达出什么以及它应该如何实现. 如果单从API文档出发,由于信息量不 ...
- Algorithm negotiation failed
#用pycharm工具ssh client 报 algorithm negotiation failed#导致原因:是ssh升级后,为了安全,默认不再采用原来一些加密算法,我们手工添加进去即可#目前出 ...