Fishing Master 贪心!!

Fishing Master 贪心!!_第1张图片
传送门
思路:
Fishing Master 贪心!!_第2张图片

代码

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define Xiaobo main
#define IO cin.tie(0),cout.tie(0),ios::sync_with_stdio(false);
using namespace std;
const int maxn=1e5+5;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll qpow(ll a,ll b,ll m){ ll ans=1; while(b){ if(b&1) ans=ans%a%m;a=a*a%m,b>>=1;} return ans; }
ll qpow(ll a,ll b){ ll ans=1;while(b>0){ if(b&1) ans=ans*a;a*=a,b>>=1; } return ans;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
ll mul(ll a,ll b,ll m){ll res=0;while(b>0) { if(b&1) res=(res+a)%m;a=(a+a)%m;b>>=1;}return res;}
int n,t,k;
int num[maxn];//记录炖鱼时间 
int Xiaobo()
{
	IO;
	cin>>t;
	while(t--) {
		cin>>n>>k;
		ll sum=0;
		int cnt=0;
		for(int i=1;i<=n;i++) {
			cin>>num[i];
			sum+=num[i];
			cnt+=num[i]/k;//记录炖当前鱼最多能抓几条鱼 
			num[i]%=k;//记录取余的结果 后面抓剩下的鱼要用到 
		}
		if(cnt>=n-1) cout<());//按再抓一条鱼需要时间多少排序 
			ll ans=sum+k;
			for(int i=1;i<=n;i++) {
				ans+=k-num[i];//ans记录再抓一条鱼所需要的时间 
				cnt++;//鱼数增加 
				if(cnt>=n-1) break;
			}
			cout<

你可能感兴趣的:(Acm之旅___HDU刷题分类,Acm之旅_贪心)