比赛 round 2『计协冻梨桐难霍』 评测结果 AAAAAAAAAAAA
题目名称 fruitFeast 最终得分 100
用户昵称 ┭┮﹏┭┮ 运行时间 0.042 s
代码语言 C++ 内存使用 3.83 MiB
提交时间 2024-11-22 08:29:07
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,ll>
#define fi first
#define in inline
#define se second
#define mp make_pair
#define pb push_back
const int N = 5e6+10;

ll read(){
	ll x = 0,f = 1;char c = getchar();
	for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
	for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
	return x * f;
}


int t,a,b;
bool f[N][2];

void dfs(int x,bool fl){ 
	if(f[x][fl])return;
	f[x][fl] = 1;
	if(x + a <= t)dfs(x + a,fl);
	if(x + b <= t)dfs(x + b,fl);
	if(!fl)dfs(x / 2,1);
}

int main(){
	freopen("fruitFeast.in","r",stdin);
	freopen("fruitFeast.out","w",stdout);
	t = read(),a = read(),b = read();
	dfs(0,0);
	for(int i = t;i >= 0;i--)
		if(f[i][0] || f[i][1])return printf("%d\n",i),0;

	return 0;

}