codeforces584B Kolya and Tanya
题目链接:http://codeforces.com/problemset/problem/584/B
解题思路:当n=1时,_______ _______ ______ 三个数每位上可以填1,2,3三个数,所以,所有可能的结果就是3*3*3 不满足条件的有2 2 2这一种情况,还有1 2 3这三个数字,总共有6种情况,所以答案是27-1-6=20;当n=2时,所有可能的结果是3*3*3*3*3*3-?=680 ,可以推测出减去49即7*7
所以找到的规律就是:
当n=1时, 27-7
当n=2时 27*27-7*7
注意点:因为最后要模上一个数,中间去模的过程中要注意
具体代码:
#include<bits/stdc++.h> using namespace std; #define LL __int64
const LL inf=; int main()
{
int n;
scanf("%d",&n);
LL ans=;
LL t=;
for(int i=;i<=n;i++)
{
ans*=;
t*=;
ans=ans%inf;
t=t%inf;
}
ans=((ans+inf)-t)%inf;
printf("%I64d\n",ans);
return ;
}
codeforces584B Kolya and Tanya的更多相关文章
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya 快速幂
B. Kolya and Tanya Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/pro ...
- CF 584B Kolya and Tanya
题目大意:3n个人围着一张桌子,给每个人发钱,可以使1块.2块.3块,第i个人的金额为Ai.若存在第个人使得Ai + Ai+n + Ai+2n != 6,则该分配方案满足条件,求所有的满足条件的方案数 ...
- Codeforces Round #324 (Div. 2) Kolya and Tanya 组合数学
原题链接:http://codeforces.com/contest/584/problem/B 题意: 有3*n个人围成一个圈,每个人可以分配1到3个硬币,但是相邻为n的三个人的和不能是6,问你有多 ...
- Codeforces Round #324 (Div. 2)解题报告
---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“ ...
- Codeforces 584 - A/B/C/D/E - (Done)
链接:https://codeforces.com/contest/584 A - Olesya and Rodion - [水] 题解:注意到 $t$ 的范围是 $[2,10]$,对于位数小于 $2 ...
- Codeforces Round #324 (Div. 2) B
B. Kolya and Tanya time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #324 (Div. 2)
CF的rating设置改了..人太多了,决定开小号打,果然是明智的选择! 水 A - Olesya and Rodion #include <bits/stdc++.h> using na ...
- CodeForces 518B. Tanya and Postcard
B. Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- codeforces 518B. Tanya and Postcard 解题报告
题目链接:http://codeforces.com/problemset/problem/518/B 题目意思:给出字符串 s 和 t,如果 t 中有跟 s 完全相同的字母,数量等于或者多过 s,就 ...
随机推荐
- cairo graphics.org
cairographics.org Latest news: 2013-08-26: cairo 1.12.16 snapshot available 2013-02-10: cairo 1.12.1 ...
- uboot代码1:uboot启动大体流程, stage1 + stage2
start.S stage 1: reset: set the cpu to svc32 mode disable the watchdog mask all IRQs(INTMSK, INTSUBM ...
- ubuntu 安装LaTex
使用IDE来使用tex,如TexMaker. 1.到http://www.tug.org/texlive/acquire-netinstall.html 下载texlive. 2.linux下命令行, ...
- 通过 Spring RestTemplate 调用带请求体的 Delete 方法(Delete With Request Body)
Spring 框架的RestTemplate 类定义了一些我们在通过 java 代码调用 Rest 服务时经常需要用到的方法,使得我们通过 java 调用 rest 服务时更加方便.简单.但是 Res ...
- poj 1564 Sum It Up | zoj 1711 | hdu 1548 (dfs + 剪枝 or 判重)
Sum It Up Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Sub ...
- CloudStack 4.2 新功能:集成SNMP进行系统监控(原理篇)
作者微博:http://weibo.com/tianchunfeng CloudStack 4.2 版本发布在即,相信不久后对 4.2 版本新功能(共有13个)的介绍会逐渐多起来.因为无论是从架构底层 ...
- 监听手机晃动(摇一摇)SensorEventListener
import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; ...
- 硬盘被误格式化或Ghost还原后的数据恢复
硬盘格式化(Ghost还原)后的数据恢复 ---diskgenius使用之数据恢复 问题引出:计算机中病毒后用Ghost版本的winxp安装,由于安装途中选择了把映像安装到硬盘而不是分区,安装好后只剩 ...
- 【环境配置】配置sdk
1. 安装和配置 (1) 下载sdk 官方下载地址http://developer.android.com/sdk/index.html 这里以android-sdk_r12-linux_x86.tg ...
- python实现刷博器(适用于新浪、搜狐)
本文总结于智普教育: 做点小东西,有成就感,才会有动力学下去哈! 先上代码: 1: import webbrowser as web 2: import time 3: import os 4: co ...