codeforces15E Triangles

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

【题解】

 

codeforces15E Triangles_第1张图片

codeforces15E Triangles_第2张图片

codeforces15E Triangles_第3张图片

codeforces15E Triangles_第4张图片

 1 # include 
 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

你可能感兴趣的:(codeforces15E Triangles)