CodeForces 185A - Plant
来源:互联网 发布:淘宝店铺的网址在哪里 编辑:程序博客网 时间:2024/06/05 06:19
1、这道题就是一道规律题。
2、看了条件,然后看了一下样例,再对比一下图,我发现每一个三角形的最下面的尖尖朝上的三角形的个数是pow(2,n),但是如果直接这样用普通的幂运算,会wa,我就wa了的,然后这里就要用到一下快速幂了!然后就可以得到一个等差数列,从1到幂运算后得到那个值用等差数列求和就解决了!
#include <iostream>#include <cstdio>#include <cmath>#include <cstdlib>#include <iomanip>#include <algorithm>#include <cctype>#include <stack>#include <queue>#include <string>#include <cstring>#include <iomanip>#include <set>#include <vector>#include <cstdio>#include <stack>#include <sstream>#include <cstring>#include <map>using namespace std;typedef long long ll;ll mod=1e9+7;ll pow3(ll a,ll b){ ll r=1,base=a; while(b) { if(b&1) r=r*base%mod; base=base*base%mod; b>>=1; } return r;}int main(){ ll n; cin>>n; ll last=pow3(2,n); //cout<<last<<endl; ll res=(1+last)*last/2; cout<<res%mod<<endl; return 0;}
0 0
- Codeforces 185A Plant
- codeforces 185A Plant
- CodeForces 185A - Plant
- CodeForces - 185A Plant
- CodeForces 185A Plant
- Codeforces 185 A Plant
- CodeForces Round #118 (185A) - Plant
- 【快速幂】 CodeForces 185A Plant
- CodeForces - 185A Plant 矩阵快速幂
- Codeforces 185A Plant 普通快速幂取模
- codeforces 185A. Plant(规律)
- codeforces 185A Plant(矩阵快速幂)
- codeforces 185A. Plant 矩阵快速幂
- CodeForces 185A. Plant (矩阵快速幂)
- codeforces 185A Plant(矩阵快速幂)
- codeforces #185 A Plant(矩阵快速幂+递推)
- CodeForces 185A. Plant(矩阵快速幂)
- CodeForces 185A. Plant(矩阵快速幂) 构造
- 用户调研如何入门
- 二级指针的三种内存模型
- 在远程ssh登陆和本地登陆时显示日期和主机名
- hdoj 1022 Train problem 1【栈 的理解】
- listview notifyDataSetChanged()刷新显示
- CodeForces 185A - Plant
- python学习第三天
- ShadowSocks翻墙原理
- websocket(二)--简单实现网页版群聊
- Select count(*)和Count(1)的区别和执行方式
- poj 3581 Sequence(后缀数组)
- Android应用Preference相关及源码浅析(SharePreferences篇)
- Android多媒体编程(待续)
- struts 2 用s 标签 输出 list 里的 map