思路

有四种方法,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的更多相关文章

  1. Count the number of possible triangles

    From: http://www.geeksforgeeks.org/find-number-of-triangles-possible/ Given an unsorted array of pos ...

  2. [ACM_搜索] Triangles(POJ1471,简单搜索,注意细节)

    Description It is always very nice to have little brothers or sisters. You can tease them, lock them ...

  3. acdream.Triangles(数学推导)

    Triangles Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit Stat ...

  4. UVA 12651 Triangles

    You will be given N points on a circle. You must write a program to determine how many distinctequil ...

  5. Codeforces Gym 100015F Fighting for Triangles 状压DP

    Fighting for Triangles 题目连接: http://codeforces.com/gym/100015/attachments Description Andy and Ralph ...

  6. 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 ...

  7. 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 ...

  8. Project Euler 94:Almost equilateral triangles 几乎等边的三角形

    Almost equilateral triangles It is easily proved that no equilateral triangle exists with integral l ...

  9. 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 ...

随机推荐

  1. beego conf配置文件

    1. 多个配置文件通过include引入 自定义配置文件mysql.conf 在app.conf 中引入mysql.conf include "mysql.conf"

  2. bootstrap基础学习【表单含按钮】(二)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  3. Mybatis之自动生成

    使用Mybatis来自动生成我们的dao接口,mapper文件和实体类. 1.pom.xml依赖: <dependencies> <dependency> <groupI ...

  4. 学习笔记:CentOS7学习之十五: RAID磁盘阵列的原理与搭建

    目录 学习笔记:CentOS7学习之十五: RAID磁盘阵列的原理与搭建 14.1 RAID概念 14.1.1 RAID几种常见的类型 14.1.2 RAID-0工作原理 14.1.3 RAID-1工 ...

  5. c# base64及MD5工具类

    using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Lin ...

  6. (十六)JDBC 处理大数据

    目录 前言: 基本概念 对于Mysql的Text类型 流地址的写法 blob类型数据 备注 前言: 在实际开发中,程序需要把 大文本或二进制 数据保存到数据库中: 实际上,我们并不存储大的数据到数据库 ...

  7. 第十一章 ZYNQ-MIZ701 PS读写PL端BRAM

      本篇文章目的是使用Block Memory进行PS和PL的数据交互或者数据共享,通过zynq PS端的Master GP0端口向BRAM写数据,然后再通过PS端的Mater GP1把数据读出来,将 ...

  8. Thread 和 Runnable

    Thread 和 Runnable 1. 简介 Java 主要是通过 java.lang.Thread 类以及 java.lang.Runnable 接口实现线程机制的. Thread 类为底层操作系 ...

  9. Idea加载项目扫描完毕后自动退出

    问题描述:Idea平时好好的,突然就打开后扫描完毕后自动退出.网上说修改idea.exe.vmoptions文件的Xmx,还是不行. 后来根据http://www.pianshen.com/artic ...

  10. python+django学习三

    在这个网站看https://sshwsfc.github.io/xadmin/     xadmin结果一堆的坑,文档找不到界面,dome登陆就报错permission denied for rela ...