首页 > 喝可乐
头像 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 展开全文