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

 

posted @ 2019-02-10 14:51  Galaxies  阅读(243)  评论(0编辑  收藏  举报