您的位置:首页 > 其它

codeforces 186C Plant

2016-09-07 00:27 369 查看
题意:每次把一个相反的(正倒相反)的三角形放到每个三角形中切割原来的图形,问n次切割后有多少个小三角形?

公式题,忘记特判0的情况wa了很多次!!!

以后一定要注意边界情况

#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define eps 1e-3
#define mod 1000000007
#define ll long long

using namespace std;

ll n, a, b;

ll pow (ll x, ll y)
{
if (y == 0)
return 1LL;
ll ret = pow (x, y / (1LL * 2)) % mod;
ret = (ret * ret) % mod;
if (y % (2 * 1ll))
ret = (ret * x) % mod;
return ret % mod;
}

int main ()
{
cin >> n;
if (n == 0)
{
printf ("1\n");
return 0;
}
ll base = 2 * 1LL;
ll b1 = n - 1LL;
ll b2 = n * (2 * 1LL) - 1LL;
//a = pow (2 * 1LL, n * 1LL- 1LL);
a = pow (base, b1);
b = pow (base, b2);
//b = pow (2 * 1LL, n * 1LL * 2 - 1LL);
cout << (a + b) % mod << endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: