0分求调
  • 板块题目总版
  • 楼主Hoshino_1
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/10/19 09:10
  • 上次更新2024/10/19 11:16:51
查看原帖
0分求调
1224861
Hoshino_1楼主2024/10/19 09:10

P1323

#include <bits/stdc++.h>
using namespace std;
priority_queue <int , vector<int> , greater<int> > pq; 
int k , m;
string ans , ans1;
int main(){
	pq.push(1);
	cin >> k >> m;
	int cnt = 0;
	while(cnt < k){
		int a = pq.top() * 2 + 1;
		int b = pq.top() * 4 + 5;
		ans += to_string(pq.top());
		pq.pop();
		pq.push(a);
		pq.push(b);
		++cnt;
	}
	cout << ans << '\n';
	int l = 0 , r = m;
	int maxx = 0;
	while(l <= r && r <= ans.size()){
		for(int i = l;i <= r;++i){
			if((ans[i] - '0') > maxx){
				maxx = (int)(ans[i] - '0');
				l = i + 1;
			}
		}
		ans1 += to_string(maxx);
		r++;
		maxx = 0;
	}
	cout << ans1;
	return 0;
}
2024/10/19 09:10
加载中...