chiaki sequence reloaded(规律+数位dp)

博客介绍了 Chiaki 定义的一个无限序列,其规律为根据二进制中相邻位数值关系确定项的增减。题目要求计算前 n 项和对 (10^9 + 7) 取模的结果。通过观察二进制模式,可以采用数位动态规划的方法解决,其中 dp[i][j][k] 表示第 i 位,当前位值为 j,总和为 k 的状态。考虑到和的范围,使用绝对值简化表示。博客提供了详细的解题思路和参考链接。
摘要由CSDN通过智能技术生成

链接:https://www.nowcoder.com/acm/contest/142/C
来源:牛客网
 

题目描述

Chiaki is interested in an infinite sequence a1, a2, a3, ..., which defined as follows:

Chiaki would like to know the sum of the first n terms of the sequence, i.e. . As this number may be very large, Chiaki is only interested in its remainder modulo (109 + 7).

输入描述:

There are multiple test cases. The first line of input contains an integer T (1 ≤ T ≤ 105), indicating the number of test cases. For each test case:
The first line contains an integer n (1 ≤ n ≤ 1018).

输出描述:

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值