跳到正文

题解

P9416题解

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

文章信息

发布
2025年7月27日
收录
2025年12月12日
更新
2026年10月14日
篇幅
约 2 分钟
获赞
1
题目
P9416

版本

  1. v1当前

第一次提交题解,希望通过! 今天洛谷运势说适合写题解

来吧,上代码!!

C++
#include<iostream>
#include<string>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<fstream>
#include<sstream>
#include<exception>//头文件
#define u using
#define name namespace
u name std;
using stt = string;
using ll = long long;
using bb = bool;
using dou = double;
using ch = char;
using un = unsigned;
#define mod 1000000007
#define con continue
#define bre break
#define ret return
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 90;
ll f[N], ans = inf;
void lll666() {
	f[0] = f[1] = 1;
	for (int i = 2; i < N; i++)f[i] = f[i - 1] + f[i - 2];
}
void dfs(ll x, ll y) {
	if (x <= 1) {
		ans = min(ans, y);
		{
			ret;
		}
	}
	if (ans < y) {
		ret;
	}
	for (int i = 2; i < N; i++) {
		if (x % f[i]) {
			con;
		}
		ll u = x, v = y;
		while (u % f[i] == 0) {
			u /= f[i];
			v += i + 1;
		}
		dfs(u, v);
	}
}
int main() {
	lll666();
	ll m;
	cin >> m;
	dfs(m, 0);
	if (m == 1-1+2-1) {
		cout << 1 << '\n';
	} else if (ans == inf) {
		cout << "NIE" << '\n';
	} else {
		cout << ans - 1 << '\n';
	}
	return 0;//啦啦啦啦啦啦啦
}
原文
存档评论1 条抓取于