zoukankan      html  css  js  c++  java
  • CF1423J Bubble Cup hypothesis 题解

    Codeforces
    Luogu

    Description.

    求满足 \(\sum_{i=0}^{+\infty}a_i2^i=m\)\(\forall i\in\mathbb N,a_i\in[0,8)\)\(\{a_i\}\) 数量。

    Solution.

    没思路

    首先,考虑这个 \(\forall i\in \mathbb N,a_i\in[0,8)\) 的限制。
    众所周知, \(8=2^3\),可以考虑按照 \(8\) 来分组,往 \(8\) 进制那边考虑。

    \[\begin{aligned} m&=\sum_{i=0}^{+\infty}a_i2^i\\ &=\sum_{3|i}(a_i\cdot2^i+a_{i+1}\cdot2^{i+1}+a_{i+2}\cdot2^{i+2})\\ &=\left(\sum_{3|i}a_i\cdot2^i\right)+2\left(\sum_{3|i}a_{i+1}\cdot2^i\right)+4\left(\sum_{3|i}a_{i+2}\cdot2^i\right)\\ &=\left(\sum_{i\in\mathbb N}a_i\cdot8^i\right)+2\left(\sum_{i\in\mathbb N}a_{i+1}\cdot8^i\right)+4\left(\sum_{i\in\mathbb N}a_{i+2}\cdot8^i\right)\\ \end{aligned} \]

    设其分别为 \(x,y,z\),则有 \(x+2\cdot y+4\cdot z=m\)
    发现如果 \(x,y,z\) 确定了,那 \(\{a_i\}\) 就确定了,因为它完全就是个八进制。

    题目意思转化成了 \(x+2\cdot y+4\cdot z=m\) 的方案数。

    \[\begin{aligned} res&=\sum_{4i\le m}\sum_{2j\le m-4i}1\\ &=\sum_{4i\le m}\left(\left\lfloor\frac{m-4i}{2}\right\rfloor+1\right)\\ &=\sum_{4i\le m}\left(\left\lfloor\frac{m}{2}\right\rfloor+1-2i\right)\\ &=\left(\left\lfloor\frac{m}{2}\right\rfloor+1\right)\cdot\left(\left\lfloor\frac{m}{4}\right\rfloor+1\right)-\left(\left\lfloor\frac{m}{4}\right\rfloor+1\right)\cdot\left\lfloor\frac{m}{4}\right\rfloor\\ \end{aligned} \]

    Coding.

    点击查看没脑子代码
    //是啊,你就是那只鬼了,所以被你碰到以后,就轮到我变成鬼了{{{
    #include<bits/stdc++.h>
    using namespace std;typedef long long ll;
    template<typename T>inline void read(T &x)
    {
    	x=0;char c=getchar(),bz=0;
    	for(;c<48||c>57;c=getchar()) if(!(c^45)) bz=1;
    	for(;c>=48&&c<=57;c=getchar()) x=(x<<1)+(x<<3)+(c^48);
    	bz?x=-x:x;
    }/*}}}*/
    const int P=1e9+7;
    inline void solve()
    {
    	ll n,x,y;read(n),x=n/2%P,y=n/4%P;
    	printf("%lld\n",((x+1)*(y+1)%P-(y+1)*y%P+P)%P);
    }
    int main() {int Ca;for(read(Ca);Ca--;) solve();return 0;}
    
  • 相关阅读:
    ExecuteScalar requires the command to have a transaction when the connection assigned to the command is in a pending
    如何从vss中分离程序
    String or binary data would be truncated
    the pop3 service failed to retrieve authentication type and cannot continue
    The POP3 service failed to start because
    IIS Error he system cannot find the file specified _找不到页面
    pku2575Jolly Jumpers
    pku2940Wine Trading in Gergovia
    pku3219二项式系数
    pku1029false coin
  • 原文地址:https://www.cnblogs.com/pealfrog/p/15116183.html
Copyright © 2011-2022 走看看