为什么 WA #1
  • 板块P3403 跳楼机
  • 楼主ikunTLE
  • 当前回复0
  • 已保存回复0
  • 发布时间2025/1/16 13:54
  • 上次更新2025/1/16 16:39:32
查看原帖
为什么 WA #1
890515
ikunTLE楼主2025/1/16 13:54
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
int read(){int x=0;char f=1,ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return x*f;}
const int N=1e5+10;
int f[N];
bool vis[N];
struct edge{
	int to,w;
};vector<edge>vc[N];
struct node{
	int x,dis;
	friend bool operator>(const node cmp_x,const node cmp_y){
		return cmp_x.dis>cmp_y.dis;
	}
};priority_queue<node,vector<node>,greater<node>>pq;
void dijkstra(){
	memset(f,0x3f,sizeof(f));
	f[1]=0,pq.push({1,0});
	while(!pq.empty()){
		node u=pq.top();pq.pop();
		if(vis[u.x])
			continue;
		vis[u.x]=true;
		for(edge i:vc[u.x]){
			int temp=u.dis+i.w;
			if(temp<f[i.to]){
				f[i.to]=temp;
				pq.push({i.to,temp});
			}
		}
	}
	return;
}
signed main(){
	int h=read()-1,a[]={0,read(),read(),read()};
	for(int i=0;i<a[1];++i)
		for(int j=2;j<=3;++j)
			vc[i].push_back({(a[j]+i)%a[1],a[j]});
	dijkstra();
	int ans=0;
	for(int i=0;i<a[1];++i)
		if(f[i]<=h)
			ans+=(h-f[i])/a[1]+1;
	printf("%llu\n",ans);
	return 0;
}

咕咕咕

2025/1/16 13:54
加载中...