博客
关于我
AT2272 [ARC066B] Xor Sum 题解
阅读量:452 次
发布时间:2019-03-06

本文共 642 字,大约阅读时间需要 2 分钟。

分析数列1, 2, 4, 5, 8, 10, 13, 14, 18时,我们发现难以直接看出明显的规律。于是,我们决定从OEIS上搜索这个数列,发现它对应于一个递推公式:

f(x) = f(x/2) + f((x-1)/2) + f((x-2)/2)

通过对递推式的分析和编写程序计算更多的数值,我们能够更深入地理解这个数列的生成规律。程序如下:

#include #include 
using namespace std;ll solve(ll xx) { if (xx <= 20) return a[xx]; if (ma[xx]) return ma[xx]; if (xx % 2) { ma[xx] = (2 * solve(xx / 2) % mod + solve(xx / 2 - 1) % mod) % mod; } else { ma[xx] = (2 * solve(xx / 2 - 1) % mod + solve(xx / 2) % mod) % mod; } return ma[xx];}int main() { ll n; scanf("%lld", &n); ll ans = solve(n); printf("%lld\n", ans); return 0;}

通过上述程序,我们可以计算出数列的后续项,并进一步分析其规律。

转载地址:http://plpyz.baihongyu.com/

你可能感兴趣的文章
Nio ByteBuffer组件读写指针切换原理与常用方法
查看>>
NIO Selector实现原理
查看>>
nio 中channel和buffer的基本使用
查看>>
NISP一级,NISP二级报考说明,零基础入门到精通,收藏这篇就够了
查看>>
NI笔试——大数加法
查看>>
NLP 基于kashgari和BERT实现中文命名实体识别(NER)
查看>>
Nmap扫描教程之Nmap基础知识
查看>>
Nmap端口扫描工具Windows安装和命令大全(非常详细)零基础入门到精通,收藏这篇就够了
查看>>
NMAP网络扫描工具的安装与使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>