目录
E – Lucky bag
题目大意:
思路解析:
代码实现:
E – Lucky bag
题目大意:
思路解析:
在方差中平均值只与输入有关为定值。看到数据范围为 2
dp[i][j] (i为二进制)表示 i二进制状态下选择了这么多个物品,使用j个背包能够达到最小的方差。
代码实现:
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
static int mod1 = (int) 1e9 + 7;
static int mod2 = 998244353服务器托管网;
static int BD = 500;
public static void main(String[] args) throws IOException {
int n = input.nextInt();
int d = input.nextInt();
int[] arr = new int[n];
double sum = 0;
for (int i = 0; i 0){
dp[i][j] = Math.min(dp[i][j], dp[i-x][j-1] + dp[x][1]);
x = (x - 1) & i;
}
}
}
out.printf("%.15f",dp[(1 = 0 && arr[left] >= arr[left + 1]) left--; // 从升序 一直往降序排列。
if (left = arr[right]) right--;
{
int t = arr[left];
arr[left] = arr[right];
arr[right] = t;
}
// 修改后它的前面仍然为降序,将前面全部修改为升序,这样能保证不会漏算,也不会算重
left++;
right = len - 1;
while (left 0) {
if ((b & 1) == 1) res = (res * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return res;
}
// // 线段树模板
// public static int lowbit(int x){
// return x & (-x);
// }
//
// public static void bulid(int n){
// for (int i = 1; i = l){
// res += t[r];
// r -= lowbit(r);
// }
// }
// return res;
// }
static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
static Input input = new Input(System.in);
static BufferedReader br = new BufferedRea服务器托管网der(new InputStreamReader(System.in));
static class Input {
public BufferedReader reader;
public StringTokenizer tokenizer;
public Input(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public String nextLine() {
String str = null;
try {
str = reader.readLine();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
return str;
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public Double nextDouble() {
return Double.parseDouble(next());
}
public BigInteger nextBigInteger() {
return new BigInteger(next());
}
}
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
Ubuntu是一个基于Linux的开源操作系统,它遵循GNU通用公共许可证,用户可以自由使用、复制、分发和修改。它提供直观易用的桌面环境,适合新手和有经验用户。Ubuntu有强大的软件中心,支持多硬件架构,注重安全和稳定,并有庞大的用户社区提供支持。它适用于桌…