dalao助我

不过大佬找到了解题的关键
image

1 个赞

这种题我一般翻到题解的最后把结论一抄然后交上去

这题正解有个很复杂的推式子啊

https://www.luogu.com.cn/user/246331
是个大佬就对了

1 个赞

这个锑(@俞天行)只会打暴力(

那你做啥?

玩(

是他?

建议使用deepseek神之力(doge)

包过不了的

1 个赞

有没有dalao给我推荐一个很水的黑题(指码量短或者好写)

woc我切不出橙题了

代码:

#include <bits/stdc++.h>
#define int long long

using namespace std;

// 计算序列中下一个数字
string next(string num) {
	// 对数字的数字进行排序以获取最大和最小的数字
	string a = num;
	string b = num;
	
	sort(a.rbegin(), a.rend()); // 降序
	sort(b.begin(), b.end());  // 升序
	
	// 转换为整数
	int sum1 = stoi(a);
	int sum2 = stoi(b);
	
	// 减去并返回为字符串
	int ans = sum1 - sum2;
	return to_string(ans);
}

// 查找进入循环的第一个数字
string find(string start) {
	set<string> seen; // “跟踪”看到的数字
	string now = start;
	
	while (true) {
		if (seen.count(now)) {
			return now; // 找到循环,返回数字
		}
		
		seen.insert(now); // 将当前编号标记为已见
		now = next(now); // 计算下一个数字
	}
}

signed main() 
{
	int n, d;
	cin >> n >> d;
	
	vector<string> a(n);

    if (d == 4) {
        while (n--) {
            cout << "6174\n";
        }
        return 0;
    } else if (d == 3) {
        while (n--) {
            cout << "495\n";
        }
        return 0;
    }
	
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		a[i] = find(s); // 找到循环编号并存储
	}
	
	for (auto it : a) {
		cout << it << '\n';
	}
	
	return 0;
}

为什么12qwq,知道问题(有时会输出0)但改不出来
@stringdp100005

0题解好机会

but12分

ber,这不就模拟吗

请另外开一个帖子

ok了,大佬帮我……