摘要:
数论+爆搜 详见这位大佬https://blog.csdn.net/eolv99/article/details/39644419 cpp include include include using namespace std; const int N=100000; int s,p[N+5],to 阅读全文
摘要:
参考:http://hzwer.com/3099.html 神题神题 其实只要知道思路就有点都不难…… 先对每一行dp,设g[i][j]为这行前i个格子粉刷了k次最大粉刷正确数,随便n^3一下就行 设f[i][j]为前i行刷了k次的最大正确数,这个用g更新即可,像背包一样 cpp include i 阅读全文
摘要:
状压dp,设f[i][j][0/1]为前i个时间段换了j间教室的期望体力消耗,转移很好想(但是写起来好长= =) cpp include include using namespace std; const int N=2005; int n,m,v,e,c[N],d[N]; double k[N] 阅读全文
摘要:
先写了个next_permutation结果T了,于是开始写状压 设f[s][i]为选取状态为s,选的数模d为i的方案数,去重的话直接除以每个数字的出现次数的阶乘即可 cpp include include include using namespace std; const int N=20; i 阅读全文
摘要:
贪心,一边读入一边更新mn,用mn更新答案,mn每次加s cpp include include using namespace std; int n,s,mn=1e9; long long ans; int main() { scanf("%d%d",&n,&s); for(int i=1,w,c 阅读全文
摘要:
C: 枚举中间点,计算两边点差值,把个数乘起来即可 cpp include include include using namespace std; const int N=200005; long long n,k,ans; int main() { scanf("%lld%lld",&n,&k) 阅读全文
摘要:
二分答案,贪心判断,洛谷上要开long long cpp include include using namespace std; const int N=50005; int n,m,a[N],b[N]; int read() { int r=0,f=1; char p=getchar(); wh 阅读全文
摘要:
直接bfs,在过程中更新方案数即可 cpp include include include using namespace std; const int N=55,inf=1e9,dx[]={1,1, 1, 1,2,2, 2, 2},dy[]={2, 2,2, 2,1, 1,1, 1}; int n 阅读全文
摘要:
设f[i]为i为牡牛的方案数,f[0]=1,s为f的前缀和,f[i]=s[max(i k 1,0)] cpp include include using namespace std; const int N=100005,mod=5000011; int n,m,f[N],s[N]; int mai 阅读全文
摘要:
神仙构造,做不来做不来 详见:http://vfleaking.blog.163.com/blog/static/174807634201329104716122/ cpp include include include include using namespace std; const int 阅读全文
摘要:
爆搜卡线过 并不知道正解是啥 cpp include include using namespace std; const int N=40; int n,ans,a[N][N],l[N],h[N],c[N]; void dfs(int x) { if(x==n+1) { ans++; return 阅读全文