博客
关于我
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/

你可能感兴趣的文章
OfficeWeb365 SaveDraw 文件上传漏洞复现
查看>>
office中的所有content type
查看>>
office之Excel 你会用 Ctrl + E 吗?
查看>>
Office办公软件里的“开发工具”选项卡-ChatGPT4o作答
查看>>
Offline Installation the .NET Framework 3.5 on Windows 8
查看>>
OGG初始化之使用数据库实用程序加载数据
查看>>
ogg参数解析
查看>>
ognl详解
查看>>
Ogre 插件系统
查看>>
Oil Deposits
查看>>
oj2894(贝尔曼福特模板)
查看>>
OJ4TH|Let's play a game
查看>>
OJ中处理超大数据的方法
查看>>
OJ中常见的一种presentation error解决方法
查看>>
OK335xS UART device registe hacking
查看>>
ok6410内存初始化
查看>>
OkDeepLink 使用教程
查看>>
OKHTTP
查看>>
Okhttp3添加拦截器后,报错,java.io.IOException: unexpected end of stream on okhttp3.Address
查看>>
OkHttp透明压缩,收获性能10倍,外加故障一枚
查看>>