90求调
  • 板块P3403 跳楼机
  • 楼主hnczy
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/8/21 18:32
  • 上次更新2024/8/21 20:55:12
查看原帖
90求调
991913
hnczy楼主2024/8/21 18:32
#include<bits/stdc++.h>
#define int long long
using namespace std;
int h,a[4],ans,dis[100005];
void bfs(int x){
	queue<int>q;
	q.push(x);
	for(int i=0;i<=a[1];i++)dis[i]=h+1;
	dis[1]=1;
	while(!q.empty()){
		int hh=q.front();
		q.pop();
		if(dis[x%a[1]]<x)continue;
		for(int i=2;i<=3;i++){
			if(hh+a[i]>=dis[(hh+a[i])%a[1]])continue;
			q.push(hh+a[i]);
			dis[(hh+a[i])%a[1]]=hh+a[i];
		}
	}
	for(int i=0;i<a[1];i++)
		if(h>=dis[i])ans+=(h-dis[i])/a[1]+1;
	printf("%lld",ans); 
}
signed main(){
	scanf("%lld%lld%lld%lld",&h,a+1,a+2,a+3);
	sort(a+1,a+4); 
	bfs(1);
	return 0;
}
2024/8/21 18:32
加载中...