思路

有四种方法,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. js 获取xxxx-xx-xx时间格式

    function getdate() { var now = new Date(), y = now.getFullYear(), m = now.getMonth() + 1, d = now.ge ...

  2. eNSP——配置通过FTP进行文件操作

    原理: FTP (File Transfer Protocol,文件传输协议)是在TCP/IP网络和Internet.上最早使用的协议之-,在TCP/IP协议族中属于应用层协议,是文件传输的Inter ...

  3. Django用户认证模块中继承AbstractUser与AbstractBaseUser重写User表的区别

    AbstractUser和AbstractBaseUser看起来十分相似,如果你不熟悉djiango的auth重写User,那你很容易弄错,导致一堆bug. 我们查看AbstractUser的源码得知 ...

  4. js 跳转传递汉字参数

    父界面: myChart.on('click', function (params) { var dataIndex = params.dataIndex; if(params.name != &qu ...

  5. Nginx 小入门记录 之 初识Nginx和环境准备(一)

    前置知识准备: 如果还不知道服务器是干什么的,只是刚踏入程序员之路的,大家还是先学习基础,虽然以下文档很简单,但至少知道为什么要学: 一般服务器环境现在基本上都是放在Linux系统上了,如果对Linu ...

  6. shell中得到当下路径所有文件夹名称

      方法1: for dir in $(ls -al ./|awk '/^d/ {print $NF}') do echo $dir done   方法2: for dir in $(ls ./) d ...

  7. Python+requests 发送简单请求--》获取响应状态--》获取请求响应数据

    Python+requests 发送简单请求-->获取响应状态-->获取请求响应数据 1.环境:安装了Python和vscode编译器(Python自带的编译器也ok).fiddler抓包 ...

  8. 【AtCoder】AGC006

    AGC006 A - Prefix and Suffix -- #include <bits/stdc++.h> #define fi first #define se second #d ...

  9. 剑指offer42:数组和一个数字S,输出两个数的乘积最小的

    1 题目描述 输入一个递增排序的数组和一个数字S,在数组中查找两个数,使得他们的和正好是S,如果有多对数字的和等于S,输出两个数的乘积最小的. 输出描述: 对应每个测试案例,输出两个数,小的先输出. ...

  10. Python基础 第三章 使用字符串(1)精简版

    所有标准序列操作(索引,切片,乘法,成员资格检查,长度,最小值,最大值)都适于字符串. 但,字符串是不可变得,故所有得元素赋值和切片赋值都是非法的. 1. %s 转换说明符 设置字符串格式 %左边指定 ...