摘要:
93. 递归实现组合型枚举 if (sum + n - u < m) return; 如果当前记录的数据 加上 后面的所有可以被选的数据 时无法达到要求时终止 state记录了哪些数据被选,哪些没被选的 state | 1 << u 选择当前的数据,比如0101 -> 10101 #include 阅读全文
摘要:
95.费解的开关 用枚举的思想,把第一行先枚举了 (通过: for (int op = 0; op < 32; op ++ ) for (int i = 0; i < 5; i ++ ) if (op >> i & 1) ) 根据第i行去trun第i+1行来改变第i行 trun的改变利用了偏移量来简 阅读全文
摘要:
二分 P8647 思路 cnt是记录获得巧克力的小朋友的数量 ans是巧克力的边长 找到满足cnt >= k 的,ans的最大值 代码 #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int n, k, h[ 阅读全文
摘要:
二分 B3880 思路 ans越小cnt越大于m 找到ans的最大值使cnt>=m 代码 #include <bits/stdc++.h> using namespace std; const int N = 1e4 + 10; int n, m, l[N], s[N], ans; // int c 阅读全文
摘要:
二分 P1918 思路 不复杂二分 代码 #include <iostream> #include <algorithm> using namespace std; typedef struct S{ int x, i; } S; int n, m; S a[100010]; int Binary( 阅读全文
摘要:
二分 P1873 思路 二分找到满足获得木材大于M的最大锯片高度 代码 #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int n, m; int a[N]; bool check(int mid) { lo 阅读全文