自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

原创 点是否在不规则图形内部

根据点穿过图形边的个数来判断

2022-06-19 21:21:09 681

原创 试题B:直线

思路: 刚开始想的是求k和b,用pair<double,double>存储,然后再用set装数,再用set.size()求,但是发现一件事,double类型好像用set就不怎么容易去重了,所以,改用直线:ax+by+c的形式。求a,b,c,所以-a/b=k,且c/b=b,所以令a=y2-y1,b=x2-x1,c=y2x1-y1x2。a是[-20,20],b是[-19,19],c是[-380,380],a,b,c都是整数,所以可以用set进行求解,再把set的cmp进行重写。 直线的确立:2个点.

2022-04-10 14:33:33 1352 1

原创 公因数游戏

第十二届蓝桥杯省赛 E-游戏 问题描述 首先规定一个正整数 n。 他首先在纸上写下一个 1 到 n 之间的数。 在之后的每一步,小蓝都可以选择上次写的数的一个约数(不能选上一个写过的数),写在纸上。 直到最终小蓝写下 1。 小蓝可能有多种游戏的方案。 例如,当 n = 6 时,小蓝有 9 种方案:(1), (2, 1), (3, 1), (4, 1), (4, 2, 1), (5, 1), (6, 1), (6, 2, 1), (6, 3, 1)。 请问,当 n = 20210509 时有多少种方案? 思路

2022-04-09 23:10:48 2930

原创 整数n分解为k个数的和

将 n 分解成k个正整数的和,有多少种分解方法? 俩种方法:动态规划,组合数 动态规划,暴力解 复杂度O(mnn) #include<bits/stdc++.h> using namespace std; #define ll long long ll dp[m][n]; // dp[i][j] 用i个数表示出j的方案数 int main(){ int n,m; cin>>n>>m; for (int j=1;j<=n;j++) dp[1][j] = 1;

2022-04-09 21:45:28 2104

原创 牛客-X-factor Chain

https://ac.nowcoder.com/acm/problem/50561 思路理解转: https://blog.youkuaiyun.com/optimjie/article/details/104548534 #include<bits/stdc++.h> using namespace std; #define ll long long const int maxn=1e4+10; const int inf=0x3f3f3f3f; int a[maxn],cnt=0; //分析参考:h

2022-04-09 20:36:14 185

原创 洛谷 P2392 kkksc03考前临时抱佛脚

https://www.luogu.com.cn/problem/P2392 #include<bits/stdc++.h> using namespace std; #define ll long long const int maxn=1e4+10; const int inf=0x3f3f3f3f; int dp[maxn],t[maxn]; int f(int n){ int sum=0; for(int i=1;i<=n;i++) cin>>t[i],sum+

2022-03-16 16:44:06 134

原创 牛客-TaoTao要吃鸡(背包dp)

https://ac.nowcoder.com/acm/problem/15030 #include<bits/stdc++.h> using namespace std; #define ll long long const int maxn=1e3+10; const int inf=0x3f3f3f3f; int dp[maxn],v[maxn],w[maxn]; //01背包 //最初想法为背包+记录,回溯判断背包满不满,然后再抓剩下的一个威力最大的装备。 //但是仔细想想,这样的话,

2022-02-25 23:27:47 269

原创 牛客-购买干草(完全背包)

https://ac.nowcoder.com/acm/problem/24979 #include<iostream> #include<algorithm> #include<string.h> using namespace std; typedef long long ll; const ll inf=0x3f3f3f3f; const int maxn=6e5+10; const int mod=1e9+7; int dp[maxn],p[maxn],c[m

2022-02-23 23:24:06 449

原创 牛客-Training Plan(区间dp+暴力枚举)

https://ac.nowcoder.com/acm/problem/14117 #include<iostream> #include<algorithm> #include<string.h> using namespace std; typedef long long ll; const ll inf=0x3f3f3f3f; const int maxn=5e2+10; const int mod=1e9+7; ll dp[maxn][maxn],a[maxn

2022-02-23 11:45:11 487

原创 POJ1753-Flip Game

http://poj.org/problem?id=1753 #include<iostream> using namespace std; typedef long long ll; char c[5][5]; int res[5][2]={{0,0},{1,0},{0,1},{-1,0},{0,-1}}; int get(int x){//二进制数一共有几个1 return x?(x&1)+get(x>>1):0; } int check(int x,int y,in

2022-01-13 19:56:56 140

原创 牛客-扫雷(概率期望)

https://ac.nowcoder.com/acm/problem/21364 用快速幂求逆元 + 连续抛k次正面硬币的变式 #include<iostream> #include<algorithm> using namespace std; const int maxn=1e5+10; typedef long long ll; const int mod=1e9+7; /*连续抛 k 次朝上的解法:   注意每次抛到正面的概率不同,设第k次抛正面概率为Pk,假设连续k

2022-01-04 23:30:26 650

原创 牛客-禁书目录(概率期望)

https://ac.nowcoder.com/acm/problem/20619 #include<iostream> #include<map> #include<vector> #include<algorithm> using namespace std; const int maxn=5e5+10; const int mod=998244353; typedef long long ll; /* 这道题没法用一般找规律找出排列组合关系式,所以转

2021-11-26 20:53:47 254

原创 牛客-k进制数(前缀和)

https://ac.nowcoder.com/acm/problem/15809 #include<iostream> #include<map> using namespace std; const int maxn=1e5+10; typedef long long ll; //首先明确一个概念 d(x)=x%(k-1)。 //原因:a[l]+a[l+1]...+a[r],其中每2个数加和≥k那么会由1和余k部分表示,也就是最终结果也由 1和余k部分表示 //数位和的变化

2021-11-25 20:38:44 307

原创 牛客-farm(随机化+前缀和定义差分)

https://ac.nowcoder.com/acm/problem/16637 #include<iostream> #include<algorithm> #include<cstdlib> #include<ctime> using namespace std; const int maxn=1e6+2; const int mod=1e9+7; typedef long long ll; //思路:我们重新给每种化肥安排序号,尽可能的不让其之间有倍

2021-11-21 16:59:37 354

原创 牛客-小咪买东西(二分01规划)

https://ac.nowcoder.com/acm/problem/14662 #include<stdio.h> #include<algorithm> #include<cmath> #include<iostream> #include<iomanip> using namespace std; const int maxn=1e5+10; typedef long long ll; const double eps=1e-8; int

2021-11-18 23:09:41 240

原创 牛客-数学考试 珂朵莉与宇宙(前缀和)

前缀和 https://ac.nowcoder.com/acm/problem/15553 代码: #include<iostream> #include<vector> #include<stdio.h> #include<algorithm> #include<cstring> #include<stack> #include<sstream> #include<math.h> #include<que

2021-11-18 20:28:22 254

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除