贪心水题
#include <stdio.h> #include <algorithm> #include <string.h> #include <queue> #include <stack> #include <map> #include <vector> using namespace std; long long ans; long long n,a,b,c; int main() { scanf("%lld%lld%lld%lld",&n,&a,&b,&c); ans=0; if(a<=b-c) ans=n/a; else { if(n>=b) { ans=(n-b)/(b-c); n=n-ans*(b-c); if(n>=b) ans++,n=n-b+c; } ans=ans+n/a; } printf("%lld\n",ans); return 0; }
时间: 2024-10-20 17:39:29