Codeforces Round #324 (Div. 2) B. Kolya and Tanya
来源:互联网 发布:curl php 可跳转 编辑:程序博客网 时间:2024/05/17 22:22
分析:
给你一个数n,让你构造出一个长度为3n的数列,其中每个数只能取1,2,3
只要存在某3个间隔分别为n的数之和为6,就是满足题意的序列。
问你这样的序列有多少。
快速幂搞一下
从反面计算,算不满足的序列,可知答案为3 ^ 2n - 7 ^ n
#include <iostream>#include <sstream>#include <iomanip>#include <vector>#include <deque>#include <list>#include <set>#include <map>#include <stack>#include <queue>#include <bitset>#include <string>#include <numeric>#include <algorithm>#include <functional>#include <iterator>#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>#include <cctype>#include <complex>#include <ctime>typedef long long LL;const double pi = acos(-1.0);const long long mod = 1e9 + 7;using namespace std;LL modexp(LL a,LL b){ LL t = 1LL; while(b != 0) { if(b % 2 == 1) t = (t * a) % mod; a = (a * a) % mod; b /= 2; } return t;}int main(){ LL n; scanf("%I64d",&n); LL ans = modexp(27,n) - modexp(7,n) + mod; ans %= mod; printf("%I64d\n",ans); return 0;}
0 0
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya
- Codeforces Round #324 (Div. 2)B. Kolya and Tanya
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya
- Codeforces Round #324 B Kolya and Tanya
- Codeforces 584 B. Kolya and Tanya (Codeforces Round #324 (Div. 2))
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya(组合数学)
- Codeforces Round #324 (Div. 2)——B. Kolya and Tanya
- Codeforces Round #324 (Div. 2) 584B. Kolya and Tanya 组合数学
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya (快速幂)
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya 思维题 数论
- cf#324 Div.2 Problem B Kolya and Tanya
- 【Codeforces Round 324 (Div 2)B】【容斥】Kolya and Tanya 环上n个3元组至少有一组和不为6
- codeforces#324(div2)B Kolya and Tanya(数论水)
- Codeforces #324 Div2 B.Kolya and Tanya(dp、思维)
- codeforces 584B Kolya and Tanya
- Codeforces Round #293 (Div. 2) -- B. Tanya and Postcard
- Git命令
- IOS开发中的几种设计模式介绍(思想)
- opencv中的reshape和resize
- Redis 客户端Jedis使用(一)
- iOS --- UIScrollView和UIPageControl的简单使用
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya
- foj2200 Problem 2200 cleaning dp
- iOS的UIDatePicker时间控件
- 详解Log4j
- Genome denovo assembly using velvet
- u-boot-2009.11移植(适用于TQ2440和MINI2440)第四篇:完善目标板外设驱动(Nor flash)
- Android 下载地址
- codevs 4248
- Longest Substring Without Repeating Characters