- 博客(19)
- 收藏
- 关注
原创 IJAwNrvoUs
搬家去牛客,搬家去牛客,牛客是个好平台,大家都来一起玩。牛客是个好平台,大家快来一起玩 https://blog.nowcoder.net/zhangjunhui(新博客地址)
2019-07-27 10:40:25
269
原创 容斥原理(二进制实现)
链接: hdu 1796 How many integers can you find 代码: #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 112; ll a[maxn],num; ll GCD(ll x,ll y) { return x%y==...
2019-03-06 21:43:17
247
原创 hdu 1176 免费馅饼
hdu1176免费馅饼题目链接 #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 2; int dp[12][maxn]; int main() { int n; while(~scanf("%d",&n)&&a...
2019-02-24 17:42:03
140
原创 洛谷P1020 导弹拦截(偏序问题,求最长不上升子列和最长上升子列的nlogn算法)
题目链接: 此前有一道更简单的二维偏序问题:hdu1541(Stars) 分析:同样是偏序问题,使用树状数组可以降低复杂度到nlogn 代码1:n^2的dp #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5 + 5; int n=0,h[maxn...
2019-02-01 22:26:42
293
原创 hdu1541——Stars(偏序问题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1541 hdu1541——Stars 二维偏序问题。之前没想过树状数组能解决这样的问题,留个纪念,之后再写一篇洛谷的题洛谷P1020 导弹拦截 注意题目中input:y升序输入 这点非常关键 代码: #include <bits/stdc++.h> using namespac...
2019-02-01 20:54:47
335
原创 洛谷P1083——差分的应用模板题
题目链接:https://www.luogu.org/problemnew/show/P1083 #include <bits/stdc++.h> using namespace std; const int maxn = 1e6+10; int n,m,r[maxn],f[maxn],a[maxn],d[maxn],s[maxn],t[maxn]; int judge(in...
2018-11-14 20:13:41
512
原创 LCIS O(n^3)和O(n^2)算法
分ai==bj和ai!=bj分别转移状态 #include <bits/stdc++.h> using namespace std; const int maxn = 3005; const int INF = (1<<31); int dp[maxn][maxn]; int main() { int n,ans=0; int a[maxn],b[maxn]; ...
2018-11-09 16:47:06
347
原创 UVa 437 DAG 动态规划
#include <bits/stdc++.h> using namespace std; const int maxn = 35; int d[maxn][5],c[maxn][5]; int n; void get_dimensions(int v[],int b,int dim) { int index=0; for(int i=0;i<3;i++) if(i!...
2018-11-08 15:18:19
162
原创 UVa 1025 ——————DAG模型 动态规划
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=245&page=show_problem&problem=3466 典型的DAG应用 #include <bits/stdc++.h> using namespace std;...
2018-11-07 23:41:34
190
原创 快速幂的应用
这篇博客归纳总结了快速幂的一些应用,快速幂只是一个工具,难点不在于实现而在于在合适的时候把它用上。选取了几个可以使用快速幂解决的问题,由显而易见到较为复杂难以辨别。 快速幂算法: 基础:(a+b)%c=(a%c+b%c)%c a*b%c=(a%c*b%c)%c; 故:a^b=a^(2^x1+2^x2+..........+2^xn) 若b为奇数,则xn为0,若b...
2018-10-24 18:48:34
449
原创 牛客了练习赛29
第一次做牛客发现比我想象的更难 第一题:https://www.nowcoder.com/acm/contest/211/A 分析:贪心策略。使负数项的脚码尽量大,整数项的脚码尽量小。开longlong #include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ...
2018-10-22 19:31:32
175
原创 刚学习dp——计蒜客跳跃游戏2
给定一个非负整数数组,假定你的初始位置为数组第一个下标。 数组中的每个元素代表你在那个位置能够跳跃的最大长度。 你的目标是到达最后一个下标,并且使用最少的跳跃次数。 例如: A = [2,3,1,1,4]A=[2,3,1,1,4],到达最后一个下标的最少跳跃次数为 22。(先跳跃 11 步,从下标 00 到 11,然后跳跃 33 步,到达最后一个下标。一共两次) 输入格式 第一行...
2018-08-28 15:28:35
144
原创 hdu 2014 multi-university training contest 1
A. http://acm.hdu.edu.cn/showproblem.php?pid=4861 暴力找几组规律,发现p-1为一轮循环。 经观察发现p-1与p互质,p-1次方也正好满足费马小定理形式(a,p互质,p为素数,a^(p-1)模p余1),可证明当i为p-1的倍数时,所有值均为1,和为p-1。于是该题只需判断包含的循环次数的奇偶性即可。 #include <bits/st...
2018-08-13 01:46:41
231
原创 codeforces #Round490div3 A,B,C
A. Mishka and Contest time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mishka started participating in a programming contest. There...
2018-07-30 00:01:44
207
原创 spoj 42 Adding Reversed Numbers
https://www.spoj.com/problems/ADDREV/ #include <iostream> #include <cmath> #include <string> using namespace std; int solve(int a) { int ans=0; while(a) { an...
2018-07-27 13:35:28
170
原创 hdu1055
#include <iostream> using namespace std; const int maxn=1005; struct Node{ int c,t,pre; double w; }; struct Node pp[maxn]; int find_node(int n,int r) { int ans; double v=-100;...
2018-07-25 21:36:40
255
原创 学校ppt2练习4
问题描述:以上是新浪微博中一奇葩贴:“我出生于1988年,直到25岁才遇到4个数字都不相同的年份。”也就是说,直到2013年才达到“4个数字都不相同”的要求。本题请你根据要求,自动填充“我出生于y年,直到x岁才遇到n个数字都不相同的年份”这句话。输入格式: 输入在一行中给出出生年份y和目标年份中不同数字的个数n,其中y在[1, 3000]之间,n可以是2、或3、或4。注意不足4位的年份要在前面补零...
2018-07-12 17:51:02
242
原创 第一章练习2题解
问题描述 每年冬天,北大未名湖上都是滑冰的好地方。北大体育组准备了许多冰鞋,可是人太多了,每天下午收工后,常常一双冰鞋都不剩。 每天早上,租鞋窗口都会排起长龙,假设有还鞋的m个,有需要租鞋的n个。现在的问题是,这些人有多少种排法,可以避免出现体育组没有冰鞋可租的尴尬场面。(两个同样需求的人(比如都是租鞋或都是还鞋)交换位置是同一种排法) 输入格式 两个整数,表示m和n 输出格式 一个...
2018-07-11 04:19:55
244
原创 上机练习1——题解
#include <iostream> #include <cmath> using namespace std; int solve(int x,int y) { return x%y==0?y:solve(y,x%y); } void swap(int &a,int &b) { int t=a; a=b,b=t; ...
2018-07-08 23:49:17
463
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅