跳到正文

个人记录

P2673 《瞿葩的数字游戏》T1-数字王国的门神

zfs732约 2 分钟
原文
文章信息与版本

文章信息

发布
2022年12月20日
收录
2025年12月12日
更新
2026年11月16日
篇幅
约 2 分钟

版本

  1. v2当前
  2. v1

题目传送门

Description\mathcal{Description}

表示斐波那契数列的第 ii 项,给定 m,nm,n 求 lim⁡k→∞(∑i=1kfi×10k−i)\lim\limits_{k \to \infty } \left( \sum\limits_{i=1}^kf_i\times10^{k-i} \right) 的第 mm 到第 nn 位。

Solution\mathcal{Solution}

推式子,在这个数前面加上 0.,转为小数,即。

∑i=1∞15[(1+520)i−(1−520)i] \sum_{i=1} ^ {\infty} \frac{1}{\sqrt5} \left[ \left( \frac{1+\sqrt{5}}{20} \right)^i- \left(\frac{1-\sqrt{5}}{20} \right)^i \right]

最后是 1089\dfrac{10}{89}。

时间复杂度 O(n)O(n),空间复杂度 O(1)O(1)。

Code\mathcal{Code}

C++
//
// Created by liliz on 2022/12/20.
//

#include <bits/stdc++.h>

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	freopen("test.in", "r", stdin);
	freopen("test.out", "w", stdout);

	int l, r, x = 10;
	cin >> l >> r;
	for (int i = 1; i <= r; i++) {
		if (i >= l) cout << x * 10 / 89;
		x = x * 10 % 89;
	}

	return 0;
}
原文