<题目链接> 题目大意: 你开始有X个裙子 你有K+1次增长机会 前K次会100%的增长一倍 但是增长后有50%的机会会减少一个 给你X,K(0<=X,K<=1e18), 问你最后裙子数量的期望值是多少(答案 mod 1e9+7) 解题分析: 一看到X,K的范围这么大,就应该想到是要推公式,找规律的题.本题的公式很好推,直接按照题意模拟即可. #include <cstdio> #include <cstring> #include <algorith…
Nastya received a gift on New Year - a magic wardrobe. It is magic because in the end of each month the number of dresses in it doubles (i.e. the number of dresses becomes twice as large as it is in the beginning of the month). Unfortunately, right a…
http://codeforces.com/problemset/problem/992/C 题意: 给你两个数x,k,k代表有k+1个月,x每个月可以增长一倍,增长后的下一个月开始时x有50%几率减1,增长k+1个月后结果是每种情况的总和除以种数. 题目要求的是增长k+1个月后的结果. 我们根据第三个样例可以推出他的增长过程 3 6 5 12 11 10 9 |     |     | | 24    22 20 18 从这个推导我们容易得出最后得到的每种情况构成一个等差数列,公差为2 结果是…
Nastya and a Wardrobe time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nastya received a gift on New Year — a magic wardrobe. It is magic because in the end of each month the number of dress…
写一下二叉树  推一下公式就出来了, 注意取模时的输出形式 #include <bits/stdc++.h> #define mem(a, b) memset(a, b, sizeof(a)) using namespace std; typedef long long LL; , INF = ; LL n, k; LL qp(LL a, LL b) { LL res = ; while(b) { ) res = res * a % MOD; a = a * a % MOD; b >&g…
http://codeforces.com/problemset/problem/305/B 题意:就是判断 p / q 等不等于那条式子算出来的值. 思路:一开始看到 1e18 的数据想了好久还是不会,暴力了一发显然错了.后来倒着想,就是 p / q(整除)的值一定要大于等于 a[i],否则就不行,每次判断完之后更新 p / q 即可,注意要判分母是否为0,因为这个RE了一次.思维僵化很严重,如果活跃一点估计很快就想出来了.吸取教训. #include <cstdio> #include &…
题目链接:http://codeforces.com/contest/876/problem/F 题解:一道简单的思维题,知道最多一共有n*(n+1)/2种组合,不用直接找答案直接用总的组合数减去不符合的也行.找不符合的就简单了.找到一个位置i,他的最左边的位置就是a[i]在二进制下是0的最靠近i的位置,所以可以先用pos[j]记录第j位是0的位置.然后最右边的也是同理.这里还处理一下a[l]=a[r]的情况如果这个相同会出现重复考虑所以可以在第一遍找最左边位置的时候做一下处理最左边的位置起码大…
https://codeforces.com/contest/1256 A:Payment Without Change[思维] 题意:给你a个价值n的物品和b个价值1的物品,问是否存在取物方案使得价值为s 题解:min(s/n,a)*n+b>=s?YES:NO #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<algorithm>…
大家好,欢迎来到codeforces专题. 今天选择的问题是1443场次的D题,这题是全场倒数第三题,截止到现在一共通过了2800余人.这题的思路不算难,但是思考过程非常有趣,这也是这一期选择它的原因. 链接:https://codeforces.com/contest/1443 废话就先说到这里,下面我们就来看题吧. 题意 给定n个整数,对于这n个整数我们可以采取两种操作.第一种操作是在数组左侧选择连续的k个整数减1,第二种操作是选择右侧的连续k个整数减1. 比如假设数组是[3, 2, 2,…
题目连链接:http://codeforces.com/contest/231 A. Team time limit per test:2 seconds memory limit per test:256 megabytes One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually…