<题目链接>

题目大意:

你开始有X个裙子 你有K+1次增长机会 前K次会100%的增长一倍 但是增长后有50%的机会会减少一个

给你X,K(0<=X,K<=1e18), 问你最后裙子数量的期望值是多少(答案 mod 1e9+7)

解题分析:

一看到X,K的范围这么大,就应该想到是要推公式,找规律的题。本题的公式很好推,直接按照题意模拟即可。

 #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; const int mod = 1e9+;
typedef long long ll; ll pow(ll x,ll y){
ll ans=;
while(y){
if(y & ) ans = (ans*x)%mod;
y >>= ;
x = (x*x)%mod;
}
return ans%mod;
} int main(){
ll x,k;
while(scanf("%lld%lld",&x,&k)!=EOF){
if(x == ){ puts("");continue; }
x %= mod; //注意这里需要先将x%一下,因为后面乘的过程中可能会爆long long
ll ans = ((pow(,k+)*x)%mod - pow(,k) + + mod ) % mod;
printf("%lld\n",ans);
}
}

2019-01-17

Codeforces 992C Nastya and a Wardrobe (思维)的更多相关文章

  1. CF思维联系– CodeForces -CodeForces - 992C Nastya and a Wardrobe(欧拉降幂+快速幂)

    Nastya received a gift on New Year - a magic wardrobe. It is magic because in the end of each month ...

  2. CodeForces 992C Nastya and a Wardrobe(规律、快速幂)

    http://codeforces.com/problemset/problem/992/C 题意: 给你两个数x,k,k代表有k+1个月,x每个月可以增长一倍,增长后的下一个月开始时x有50%几率减 ...

  3. CF992C Nastya and a Wardrobe 数学 第四道

    Nastya and a Wardrobe time limit per test 1 second memory limit per test 256 megabytes input standar ...

  4. Nastya and a Wardrobe CodeForces - 992C(规律)

    写一下二叉树  推一下公式就出来了, 注意取模时的输出形式 #include <bits/stdc++.h> #define mem(a, b) memset(a, b, sizeof(a ...

  5. Codeforces 305B:Continued Fractions(思维+gcd)

    http://codeforces.com/problemset/problem/305/B 题意:就是判断 p / q 等不等于那条式子算出来的值. 思路:一开始看到 1e18 的数据想了好久还是不 ...

  6. codeforces 876 F. High Cry(思维)

    题目链接:http://codeforces.com/contest/876/problem/F 题解:一道简单的思维题,知道最多一共有n*(n+1)/2种组合,不用直接找答案直接用总的组合数减去不符 ...

  7. 【CF1256】Codeforces Round #598 (Div. 3) 【思维+贪心+DP】

    https://codeforces.com/contest/1256 A:Payment Without Change[思维] 题意:给你a个价值n的物品和b个价值1的物品,问是否存在取物方案使得价 ...

  8. codeforces 1443D,解法简单,思维缜密的动态规划问题

    大家好,欢迎来到codeforces专题. 今天选择的问题是1443场次的D题,这题是全场倒数第三题,截止到现在一共通过了2800余人.这题的思路不算难,但是思考过程非常有趣,这也是这一期选择它的原因 ...

  9. Codeforces Round #143 (Div. 2) (ABCD 思维场)

    题目连链接:http://codeforces.com/contest/231 A. Team time limit per test:2 seconds memory limit per test: ...

随机推荐

  1. Confluence 6 后台中的默认空间模板设置

    Confluence 6 后台中的默认空间模板设置界面的布局. https://www.cwiki.us/display/CONFLUENCEWIKI/Customizing+Default+Spac ...

  2. 用echarts写的轨迹图demo

    轨迹图预览: [下载地址]:https://github.com/zhangzn3/trail-graph.git

  3. 广工赛-hdu6470矩阵快速幂

    递推时把(n+1)^3拆开 构造矩阵即可 #include<bits/stdc++.h> using namespace std; #define ll long long #define ...

  4. C++ 使用system()实现锁定屏幕

    除了使用函数“LockWorkStation()”实现锁定屏幕,参考:http://www.cnblogs.com/Satu/p/8183081.html 此外,也可以使用函数“system()”来实 ...

  5. 集腋成裘-01-html -html基础

    1 标签 1.1 单标签 注释标签 <!-- 注释标签 --> 换行标签 <br/> 水平线 <hr/> <img src="图片来源" ...

  6. A.Ocean的礼物线段树

    A: Ocean的礼物  Time Limit: 2 s Memory Limit: 128 MB  Submit My Status  Problem Description  皇家理工存在一段很神 ...

  7. alpha冲刺1/10

    目录 摘要 团队部分 个人部分 摘要 队名:小白吃 组长博客:hjj 作业博客:来自双十一的爱 团队部分 后敬甲(组长) 过去两天完成了哪些任务 文字描述 Alpha版本的任务细分安排 leangoo ...

  8. Understanding about numerical stability, convergence and consistency

    In a computer simulation of the real world, physical quantities, which usually have continuous distr ...

  9. NEST - 编写查询

    Writing queries Version:5.x 英文原文地址:Writing queries 将数据索引到了 Elasticsearch 之后,就可以准备搜索它们了.Elasticsearch ...

  10. mysql-5.7.10-winx64 绿色版安装办法

    mysql-5.7.10-winx64 绿色版安装办法 为了防止安装程序造成电脑系统冗余,经过测试,终于将绿色版的mysql for windows安装成功.当然很多是从事百度搜索到的,但作为一种积累 ...