数学
数学知识
white Era
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
HDU6106(容斥问题)
题目:https://acm.hdu.edu.cn/showproblem.php?pid=6106 思路: 把题目给的七个数据画出文氏图,根据容斥定理就可以算出每个班的人数 AC代码: //容斥定理,把那个三集合的文氏图画出来就求出解了 #include <bits/stdc++.h> using namespace std; int main(){ int n,t; int a[8]; scanf("%d",&t); while(t--){原创 2021-08-17 13:07:54 · 111 阅读 · 0 评论 -
数论容斥定理+鸽舍定理
容斥定理理论: 模板例题: 这应该是一道入门题 思路:把三个数的整数看成三个集合,然后根据上面那个文氏图就可以求出来 #include <iostream> #include <stdio.h> #include <stdlib.h> using namespace std; /* 题目:电灯泡 有编号1-n个灯泡,每个灯泡有个开关 1.所有灯泡初始时不亮的 2.小白分别进行三次操作 3.每次操作选了一个质数x,将x和x的倍数开关都驱动一下,如果灯泡亮的那么就改成不原创 2021-08-16 17:42:08 · 253 阅读 · 0 评论 -
矩阵快速幂模板+例题
相关知识学习往这边–》https://blog.youkuaiyun.com/wust_zzwh/article/details/52058209 搞懂了模板想怎么写就怎么写,看个人 整数快速幂模板: #include <iostream> #include <stdio.h> #include <stdlib.h> using namespace std; long long fastpow(int x,int n){ long long ans = 1; lo原创 2021-08-15 18:10:49 · 296 阅读 · 0 评论 -
判断点是否在多边形内(射线法)
判断一个点是否在多边形内的方法有很多,这里是射线法 看图可以知道,在判断的点上画一条水平线,看这条线与多边形的交点,任意一边的点是奇数个,那么该点就在多边形内(因为一条水平线与多边形的交点是偶数个,如果该点在多边形内,那么它的左边或右边相交的点必定是奇数个,所以只要判断一边的情况就行了) 根据两点式可以求出水平线与多边形任意两个相邻点的交点 两点式公式: 代码: #include <iostream> using namespace std; struct Point{ double x原创 2021-08-05 21:16:26 · 2205 阅读 · 0 评论 -
二分查找(找第一个大于k的位置)
没事写了写怎么实现的二分的小操作 #include <iostream> using namespace std; const int N = 10000; int a[N],b[N]; void Sort(int l,int r,int a[]){ //归并 int mid = (l+r) >> 1; if(l == r) return ; Sort(l,mid,a); Sort(mid+1,r,a); int i = l,t = l,j = mid+原创 2021-08-04 20:50:10 · 1218 阅读 · 0 评论 -
A. Find The Array
题目:https://codeforces.com/contest/1550/problem/A Let’s call an array a consisting of n positive (greater than 0) integers beautiful if the following condition is held for every i from 1 to n: either ai=1, or at least one of the numbers ai−1 and ai−2 exists原创 2021-07-24 21:08:38 · 189 阅读 · 0 评论 -
Ball Dropping
思路: 首先我们要知道相似三角的概念,就是两个相似三角形每条对应的边成比例 剩下的看图: AC代码: #include <iostream> #include <math.h> #include <stdio.h> using namespace std; int main(){ double r,a,b,h; scanf("%lf%lf%lf%lf",&r,&a,&b,&h); .原创 2021-07-31 15:12:22 · 283 阅读 · 0 评论 -
B. Maximum Cost Deletion
题目:https://codeforces.com/contest/1550/problem/B You are given a string s of length n consisting only of the characters 0 and 1. You perform the following operation until the string becomes empty: choose some consecutive substring of equal characters, eras原创 2021-07-25 10:11:18 · 328 阅读 · 0 评论 -
D. Excellent Arrays
题目:https://codeforces.com/contest/1550/problem/D Let’s call an integer array a1,a2,…,an good if ai≠i for each i. Let F(a) be the number of pairs (i,j) (1≤i<j≤n) such that ai+aj=i+j. Let’s say that an array a1,a2,…,an is excellent if: a is good; l≤ai≤r f原创 2021-07-25 17:44:16 · 290 阅读 · 0 评论 -
最大间隙问题
最大间隙问题,,鸽舍原理。。。 #include <iostream> using namespace std; const int SIZE = 10000; int n; //数据个数 double nums[SIZE]; //数据数组 int c[SIZE]; //统计每个抽屉里面有多少个数 double low[SIZE]; //记录每个抽屉里最小数 double high[SIZE]; //记录每个抽屉里最大数 double Min() { //求最小值函数 double t原创 2021-06-18 18:23:27 · 129 阅读 · 0 评论 -
最多约数问题
最多约数问题 第一个肯定是暴力解法,这读了点书的都看得懂 void Solution1() { int a, b; cin >> a >> b; // 输入a,b值 int maxCount = 0; int maxNum; //在a,b的范围内找最多约数的数 for (int i = a; i <= b; i++) { int tempNum = i; int tempCount = 1; for (int j = 1; j <=原创 2021-06-17 21:28:28 · 286 阅读 · 0 评论 -
字典序问题
知道可以用排列方法做,就是难写出好的算法。。废话少说上代码! #include using namespace std; //求排列数 int C(int n, int i) { int a, b; a = b = 1; int k = i, m = n; while (k && m) { //分子 a *= m; m--; k--; } while (i) { b *= i; i--; } return a / b; } void Solution() { int n;原创 2021-06-17 15:50:54 · 132 阅读 · 0 评论
分享