日照香炉生紫烟
查看原帖
日照香炉生紫烟
1004888
Genius_physicist楼主2024/6/9 22:14

大佬们,为什么是全???

#include <bits/stdc++.h>
//#include<windows.h>
using namespace std;
const long long N = 1e9;
bool isfb[N];
int main() {
//	system("chcp 65001");
//	system("cls");
	long long f1 = 1, f2 = 1, f3 = f1 + f2;
	for(int i = 1; i <= 43; i++) {
		isfb[f3] = 1;
		f1 = f2;
		f2 = f3;
		f3 = f1 + f2;
		//cout << f1 << " + " << f2 << " = " << f3 << "\n";
	}
	int t, a;
	cin >> t;
	while(t--){
		cin >> a;
        stack<int> stk;
        for(int j = a;j >= 1;j--) {
            if(isfb[j] && a > 0) {
                 stk.push(j);
                 a -= j;
                 j = a + 1;
            }
            if(a == 0) {
				break;
			}
        }
    	cout << a << "=" << stk.top(); 
        stk.pop();
        while(!stk.empty()) {
        	cout << "+" << stk.top();
            stk.pop();
        }
    	puts("");
    }
	return 0;
}
2024/6/9 22:14
加载中...