首页
比赛
tracker
题库
课程
竞赛讨论区
登录
/
注册
去牛客
首页
>
喝可乐
9条解析
开通博客写题解
qingshan_12
发表于 2021-04-17 22:56:16
思路枚举第一次选择的所有可能的情况,当第一次的情况确定后,就能获得这种情况能喝到的饮料数,取最大值即可代码 #include<bits/stdc++.h> using namespace std; int t, n, a, b; inline int pan(int x, int y)
展开全文
水题杀手heng
发表于 2021-04-19 21:49:31
#include<iostream> #include<iomanip> #include<cmath> using namespace std; typedef long long ll; int ma
展开全文
AliLexiWalker
发表于 2026-03-29 10:27:51
这题就把“空瓶换可乐”当成状态转移:先枚举初始买了多少瓶蜂蜜(剩下是生姜),然后一直兑换到不能换为止,取能喝最多的方案。 为了快一点,每次不是换一瓶,而是同一种能换多少就一次性全换,这样循环次数很少,整体基本就是 O(n)。 void solve(){ int n,a,b;cin>>n
展开全文
让伤痛为我加冕
发表于 2026-03-29 17:03:38
#include <iostream> #include<vector> using namespace std; int pingshu(int x,int y,int a,int b){ int N=x+y; int x1=x,x2=x; int
展开全文
IA3000
发表于 2026-03-29 21:02:45
#include <bits/stdc++.h> using namespace std; void solve() { int n, A, B; cin >> n >> A >> B; int ans = n; fo
展开全文
BeauWill
发表于 2026-03-29 02:29:50
枚举其中一种可乐的数量(此处为蜂蜜可乐)记为j,另一种可乐的数量即为k = N - j,模拟直至无法进行兑换,取最大值即为答案。粗略估一下时间复杂度为O(T * N * log),此处的log应该是与a和b相关的一个对数常数。最大的数据量大概在1E6到1E7左右,因此不会超时。 #include &
展开全文
牛客908551566号
发表于 2026-03-29 23:01:54
#include <cstdio> #include <iostream> #include <algorithm> using namespace std; // 模拟兑换过程 int simulate(int honey_start, int ginger_
展开全文
olone
发表于 2026-03-29 11:22:04
import java.util.*; public class Main{ static Scanner in = new Scanner(System.in); static void solve(){ int n = in.nextInt();
展开全文
腌萝卜干
发表于 2026-03-29 11:31:14
直接枚举第一种可乐和第二种可乐的数量然后计算最大值即可 #include <bits/stdc++.h> #define x first #define y second #define all(x) x.begin(), x.end() #define vec1(T, name, n
展开全文
查看本题
查看本题讨论
相关比赛
11210-牛客小白月赛33
进入比赛
14431-牛客小白月赛33内测
进入比赛
19662-测试摸底赛
进入比赛
49585-私人
进入比赛
52817-省赛选拔2
进入比赛
等你来战
查看全部
2026年浙江工业大学之江学院程序设计竞赛
报名截止时间:2026-04-11 16:00
2026年深圳大学-腾讯云程序设计竞赛
报名截止时间:2026-04-12 15:00
北华大学第十三届大学生程序设计竞赛(同步赛)
报名截止时间:2026-04-12 18:30
牛客周赛 Round 139
报名截止时间:2026-04-12 21:00
牛客练习赛151
报名截止时间:2026-04-17 21:30
牛客周赛 Round 140
报名截止时间:2026-04-19 21:00
哈尔滨华德学院第十七届程序设计竞赛(同步赛)
报名截止时间:2026-05-31 20:00
扫描二维码,关注牛客
意见反馈
下载牛客APP,随时随地刷题