Codeforces Round #324 (Div. 2) B. Kolya and Tanya 思维题 数论
来源:互联网 发布:i5处理器编程够用么 编辑:程序博客网 时间:2024/05/21 14:55
http://codeforces.com/contest/584/problem/B
题意:给你3n个点,均匀分散在一个圆的周围,每三个下标符合i,i+n,i+2n的点构成一个组合,
每个点可取a=1,2,3,三个数字,问给定了n后,求出有多少种圆中不存在任何一种ai+a(i+n)+a(i+2n)=6的
组合数;
错因分析:核心思想分析的出来,就是不会处理计算;
分析:若 a>b,则(a-b)%m==(a%m-b%m+m)注意中间要加个m,因为可能a%m<b%m;
AC代码:
WA代码:#include <iostream>
#include<cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include<map>
#include <algorithm>
#include <set>
using namespace std;
#define MM(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef unsigned long long ULL;
const int mod = 1000000007;
const double eps = 1e-10;
const int inf = 0x3f3f3f3f;
int main()
{
int n;
while (~scanf("%d", &n))
{
ll s = 27, w = 7;
for (int i = 1; i <= n - 1; i++)
{
s = (s * 27) % (1000000000 + 7);
w = (w * 7) % (1000000000 + 7);
}
printf("%lld\n", ( s-w+1000000000+7)%(1000000000+7));
}
return 0;
}
#include <iostream>
#include<cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include<map>
#include <algorithm>
#include <set>
using namespace std;
#define MM(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef unsigned long long ULL;
const int mod = 1000000007;
const double eps = 1e-10;
const int inf = 0x3f3f3f3f;
int main()
{
int n;
while (~scanf("%d", &n))
{
ll s = 27, w = 7;
for (int i = 1; i <= n - 1; i++)
{
s = (s * 27) % (1000000000 + 7);
w = (w * 7) % (1000000000 + 7);
}
printf("%lld\n", s-w);
}
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 (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#324(div2)B Kolya and Tanya(数论水)
- Codeforces #324 Div2 B.Kolya and Tanya(dp、思维)
- cf#324 Div.2 Problem B Kolya and Tanya
- 【Codeforces Round 324 (Div 2)B】【容斥】Kolya and Tanya 环上n个3元组至少有一组和不为6
- codeforces 584B Kolya and Tanya
- Codeforces Round #293 (Div. 2) -- B. Tanya and Postcard
- poj 3111 K Best 二分搜索 最大化平均值
- POj 3258 River Hopscotch 二分搜索 最大化最小值
- poj 2674 Linear world 弹性碰撞 升级的蚂蚁
- poj 2785 4 Values whose Sum is 0
- Codeforces Round #324 (Div. 2) A. Olesya and Rodion 构造数字 思维题
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya 思维题 数论
- Poj 3977 Subset 折半枚举 超大背包
- poj 2549 Sumsets 折半枚举
- poj 3276 Face The Right Way 挑战150 反转
- poj 3279 Fliptile 反转
- poj 3185 The Water Bowls 反转(开关)
- poj 1930 Dead Fraction 循环小数的处理
- poj 3421 X-factor Chains 素数筛选 因子分解
- poj 3292 Semi-prime H-numbers 素数变形+打表+筛选法