首页 > TAG信息列表 > problem

Problem P30. [算法课分支限界法]组合

分支树的思想遍历所有可能性,然后加上限制条件,剪枝掉不符合条件的分支,比如只能选出k个数进行组合,那么curk==k时结束这个分支,还有就是注意边界的问题,curn>n。 #include<iostream> #include<bits/stdc++.h> #include<cstdio> #include<string> using namespace std; vector<stri

结对编程队友代码分析

一.简介 本博客是对伍淇铨同学的个人项目代码的评价与分析,此项目是为中小学生自动生成数学试卷,代码思路清晰,结构严谨,功能实现完整。 二.需求分析 1、命令行输入用户名和密码,两者之间用空格隔开(程序预设小学、初中和高中各三个账号,具体见附表),如果用户名和密码都正确,将根据账户类型显

结对编程代码互评

一、介绍 本博客是对结对编程队友王同学编写的个人项目的分析评价,编写语言为java。 二、项目需求 用户:小学、初中、高中数学老师。 主要功能:输入用户名和密码登录,可以操作生成小初高数学卷子,题目不重复,保存在.TXT文件中。 题目要求: 小学 初中 高中 难度要求 +,-,*./ 平方、

Problem P12. [算法课动态规划]背包问题

01背包问题,每件物品都有放和不放这两种选择。 使用动态规划思想:有n件物品情况下的总价值最大背包和有n-1件物品情况下的总价值最大背包有关。 我也讲不大明白,对背包问题有兴趣的可以去这看看:https://zhuanlan.zhihu.com/p/93857890 #include<iostream> #include<bits/stdc++.h>

洛谷 P4137 Rmq Problem mex 莫队 + 值域分块

Rmq Problem / mex 题目描述 有一个长度为 \(n\) 的数组 \(\{a_1,a_2,\ldots,a_n\}\)。 \(m\) 次询问,每次询问一个区间内最小没有出现过的自然数。 输入格式 第一行,两个正整数 \(n,m\)。 第二行,\(n\) 个非负整数 \(a_1, a_2, \ldots , a_n\)。 接下来 \(m\) 行,每行两个正整数 \(l,

Problem P11. [算法课动态规划]爬楼梯

动态规划当前状态和前一状态相关。到m阶楼梯的方法等于到m-1和m-2的方法相加 #include<iostream> #include<bits/stdc++.h> #include<cstdio> using namespace std; int n; int cnt[25]; int main() { scanf("%d", &n); cnt[0] = 1; cnt[1] = 1; for (int

Problem with input() in Spyder 5.1.5 (Anaconda)

Problem with input() in Spyder 5.1.5 (Anaconda) 错误提示 Traceback (most recent call last):  File "C:\Users\clu\Anaconda3\lib\site-packages\qtconsole\base_frontend_mixin.py", line 138, in _dispatch    handler(msg)  File "C:\Users\clu\

MathProblem 80 128 pennies and a blindfold problem

You are blindfolded before a table. On the table are a very large number of pennies. You are told 128 of the pennies are heads up and the rest are tails up. How can you create two subgroups of pennies, each with the same number of heads facing up? Solutio

Problem P04. [算法课分治] 找到 k 个最小数

先sort排序,在输出最小的k个数。 #include<iostream> #include<bits/stdc++.h> #include<cstdio> using namespace std; int n, k; int arr[10005]; int main() { scanf("%d %d", &n, &k); for (int i = 0; i < n; i++){ scan

Problem P05. [算法课分治] 寻找第 k 个最大元素

先sort进行排序,然后输出第k大的元素即可 #include<iostream> #include<bits/stdc++.h> #include<cstdio> using namespace std; int n, k; int arr[10005]; int main() { scanf("%d %d", &n, &k); for (int i = 0; i < n; i++){

CF1513 E Cost Equilibrium / F Swapping Problem

E 先做差,发现排列如果出现正负正负或负正负正就会挂,调整一下匹配即可使min变大 同时如果正和负都>1,则不存在中间一段左右两段其他的,这样也会挂 然后随便组合一下 F 手玩发现调整的一定是a1<b1,a2>b2,且a1<a2,b2<b1才会优 则讨论发现有b2 a1 a2 b1,b2 a1 b1 a2,a1 b2 a2 b1,a1 b2 b1 a2四

CF464E The Classic Problem

传送门 思路 \(2^{100000}\) ?别想了,普通高精度肯定不行 但我们发现,求最短路的过程中,其实是用到了比较大小和加法操作 细想比较大小的过程,当长度相同的数,我们会先略过前面相同的部分,比较第一个不同的数字,时间大部分都耗在了相同部分的枚举上 我们就可以使用二分,找出第一个不同的数

MathProblem 52 Two children problem

A woman is chosen at random among all women that have two children. She is asked do you have at least one boy, and she answers 'yes.' What is the probability her other child is a boy? Assume every pregnancy has a 50/50 chance to be a boy or a gi

MathProblem 42 Drunken walk problem #1

A drunk is on one point of an n-gon, such that n is an even number. The drunk moves along the perimeter of the n-gon. Each steps takes him to an adjacent point, and every step is chosen at random. What is the expected number of steps before he arrives at

MathProblem 37 Common birthday problem

What is the minimum number of people do you need, chosen at random, so that there is at least a 50% chance that at least two have the same birthday. Assume that people are born randomly throughout the year. You may ignore leap day. Solution 假设一年有 365天,假

MathProblem 38 Meeting at a restaurant problem

Two people arrive in a restaurant independently. Each arrives a random time between 5pm and 6pm, distributed uniformaly (no moment in this range is any more likely for arrival than another). What is the probability they arrived within 10 minutes of each o

MathProblem 35 Light bulb problem #1

You have ten light bulbs. Five have an average life of 100 hours, and the other five have a average life of 200 hours. These light bulbs have a memoryless property in that their current age (measured in how long they have already been on) has no bearing o

MathProblem 34 Drug test problem

10% of the people in a certain population use an illegal drug. A drug test yields the correct result 90% of the time, whether the person uses drugs or not. A random person is forced to take the drug test and the result is positive. What is the probability

CF464E The Classic Problem(线段树 最短路)

CF464E The Classic Problem \(\bigstar\texttt{Hint}\):发现没有什么好的突破口?为什么不想想怎样才能实现题目中 \(2^x\) 的加减法呢? 可见每次加减法,我们要做的是将添加的 \(1\) 和右边的连续的 \(1\) 合并为一整段,可以用线段树 \(\mathcal{O(\log n)}\) 实现。 怎样比较大小呢?考

MathProblem 28 Furniture factory problem

A factory that produces tables and chairs is equipped with 10 saws, 6 lathes, and 18 sanding machines. It takes a chair 10 minutes on a saw, 5 minutes on a lathe, and 5 minutes of sanding to be completed. It takes a table 5 minutes on a saw, 5 minutes on

MathProblem 24 Baby bottle problem

You need to warm milk in a baby bottle from its initial temperature of 15 degrees centigrade to 25 degrees. You put the bottle in a pot of boiling water which stays at constant temperature of 100 degrees. The thickness and conductivity of the bottle are s

MathProblem 17 Dartboard problem #1

A dart is thrown at a circular dart board of radius one. The dart can land at any place on the dartboard with equal probability. What is the mean distance between where the dart hits and the center of the board? Solution 一个半径为 \(1\) 的圆盘,向上面投掷飞镖,

CF464E The Classic Problem

下面的讨论默认 \(n,m,x_i\) 同阶。 这个问题与常规 \(\tt dij\),仅仅差在高精度。而 \(\tt dij\) 所需的高精度如下: \(dis_u+w(u,v)\) 中的加法,应该有 \(m\) 次。 \(dis_u+w(u,v)\) 与 \(dis_v\) 的比较,应该有 \(m\log\) 次。 考虑数据结构维护 \(dis\) 的二进制分解。直接维护

MathProblem 23 Fork in the road problem

You are traveling down a path and come to a fork in the road. A sign lays fallen at the path indicating that one path leads to a village where everyone tells the truth and the other to a village where everyone tells lies. The sign has been knocked down so

MathProblem 16 Two coins problem

A box contains two coins. One coin is heads on both sides and the other is heads on one side and tails on the other. One coin is selected from the box at random and the face of one side is observed. If the face is heads what is the probability that the ot