codeforces15E Triangles

传送门:http://codeforces.com/problemset/problem/15/E

【题解】

 

 1 # include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 typedef long long ll;
 5 
 6 const int mod = 1e9 + 9;
 7 
 8 int main() {
 9     int n;
10     cin >> n;
11     n >>= 1;
12     
13     int t = 1, tem, res = 0, pwr = 2;
14     for (int i=2; i<=n; ++i) {
15         pwr <<= 1;
16         if(pwr >= mod) pwr -= mod;
17         tem = pwr - 3;
18         if(tem <= mod) tem += mod;
19         t = 1ll * t * tem % mod;
20         res = res + t;
21         if(res >= mod) res -= mod;
22     }
23     
24     res = 4ll * res % mod;
25     
26     int ans = 8ll * res % mod + 10;
27     if(ans >= mod) ans -= mod;
28     ans = ans + 2ll * res * res % mod;
29     if(ans >= mod) ans -= mod;
30     
31     cout << ans;
32         
33     return 0;    
34 }
View Code

 

转载于:https://www.cnblogs.com/galaxies/p/codeforces15e.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值