commit
59632ede27
@ -0,0 +1,5 @@
|
||||
*/cmake-build-debug/
|
||||
*.sql.gz
|
||||
/TangDou/cmake-build-debug-mingw
|
||||
/TangDou/cmake-build-debug
|
||||
/TangDou/*.exe
|
@ -0,0 +1,85 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"any": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"bitset": "cpp",
|
||||
"cctype": "cpp",
|
||||
"cfenv": "cpp",
|
||||
"charconv": "cpp",
|
||||
"chrono": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"compare": "cpp",
|
||||
"complex": "cpp",
|
||||
"concepts": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"coroutine": "cpp",
|
||||
"csetjmp": "cpp",
|
||||
"csignal": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cuchar": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"forward_list": "cpp",
|
||||
"list": "cpp",
|
||||
"map": "cpp",
|
||||
"set": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"regex": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"numbers": "cpp",
|
||||
"ostream": "cpp",
|
||||
"ranges": "cpp",
|
||||
"scoped_allocator": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"span": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"valarray": "cpp",
|
||||
"variant": "cpp"
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++.exe 生成活动文件",
|
||||
"command": "C:\\TDM-GCC-64\\bin\\g++.exe",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"${file}",
|
||||
"-o",
|
||||
"${fileDirname}\\${fileBasenameNoExtension}.exe"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "调试器生成的任务。"
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,23 @@
|
||||
共136题
|
||||
|
||||
[AcWing 语法基础课 笔记](https://blog.csdn.net/PxxxxN/article/details/113032355)
|
||||
|
||||
1. A + B
|
||||
https://www.acwing.com/problem/content/1/
|
||||
|
||||
608. 差
|
||||
https://www.acwing.com/problem/content/610/
|
||||
|
||||
604. 圆的面积
|
||||
https://www.acwing.com/problem/content/606/
|
||||
|
||||
606. 平均数1
|
||||
https://www.acwing.com/problem/content/608/
|
||||
|
||||
609. 工资
|
||||
https://www.acwing.com/problem/content/611/
|
||||
|
||||
615. 油耗
|
||||
https://www.acwing.com/problem/content/617/
|
||||
|
||||
TODO
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
https://www.cnblogs.com/fusiwei/p/11559403.html
|
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
vector<int> v(0);
|
||||
|
||||
int x;
|
||||
|
||||
int main() {
|
||||
vector<int>::iterator iter;
|
||||
v.insert(v.begin(), 1);
|
||||
v.insert(v.begin(), 2);
|
||||
v.insert(v.begin(), 3);
|
||||
v.insert(v.begin(), 4);
|
||||
v.push_back(5);
|
||||
|
||||
for (iter = v.begin(); iter != v.end(); ++iter)
|
||||
cout << *iter << " ";
|
||||
|
||||
cout << v.empty() << endl;
|
||||
cout << v.size()<< endl;
|
||||
v.clear();
|
||||
v.erase(v.begin());
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
【鱼同学的算法讲堂】一听就会的超基础数据结构
|
||||
https://www.bilibili.com/video/av39988212
|
After Width: | Height: | Size: 822 KiB |
Binary file not shown.
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problem/P1010
|
@ -0,0 +1,40 @@
|
||||
#include<iostream>
|
||||
#include <stdlib.h>
|
||||
using namespace std;
|
||||
int main() {
|
||||
char a[13];
|
||||
int sum=0;
|
||||
for(int i=0; i<13; i++) {
|
||||
cin >>a[i];
|
||||
}
|
||||
|
||||
|
||||
int k=0;
|
||||
for(int i=0; i<11; i++) {
|
||||
if(a[i]!='-') {
|
||||
k++;
|
||||
int b=a[i]-48;
|
||||
sum+=b*k;
|
||||
}
|
||||
}
|
||||
|
||||
int c=sum%11;
|
||||
char c2;
|
||||
if(c==10) {
|
||||
c2='X';
|
||||
} else {
|
||||
c2=c+48;
|
||||
}
|
||||
|
||||
if(c2==a[12]) {
|
||||
cout<<"Right"<<endl;
|
||||
return 0;
|
||||
} else {
|
||||
a[12]=c2;
|
||||
for(int i=0; i<13; i++) {
|
||||
cout<<a[i];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problem/P1055#submit
|
@ -0,0 +1,66 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
char c[100001];
|
||||
int a,b,i,j,k,n;
|
||||
int main()
|
||||
{
|
||||
for(n=1;;++n)
|
||||
{
|
||||
cin>>c[n];
|
||||
if(c[n]=='E')
|
||||
break;
|
||||
}
|
||||
a=0;
|
||||
b=0;
|
||||
for(i=1;i<n;++i)
|
||||
if(c[i]=='W')
|
||||
{
|
||||
++a;
|
||||
if(a>=11)
|
||||
if((a-b)>=2)
|
||||
{
|
||||
cout<<a<<':'<<b<<endl;
|
||||
a=0;
|
||||
b=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++b;
|
||||
if(b>=11)
|
||||
if((b-a)>=2)
|
||||
{
|
||||
cout<<a<<':'<<b<<endl;
|
||||
a=0;
|
||||
b=0;
|
||||
}
|
||||
}
|
||||
cout<<a<<':'<<b<<"\n\n";
|
||||
a=0;
|
||||
b=0;
|
||||
for(i=1;i<n;++i)
|
||||
if(c[i]=='W')
|
||||
{
|
||||
++a;
|
||||
if(a>=21)
|
||||
if((a-b)>=2)
|
||||
{
|
||||
cout<<a<<':'<<b<<endl;
|
||||
a=0;
|
||||
b=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++b;
|
||||
if(b>=21)
|
||||
if((b-a)>=2)
|
||||
{
|
||||
cout<<a<<':'<<b<<endl;
|
||||
a=0;
|
||||
b=0;
|
||||
}
|
||||
}
|
||||
cout<<a<<':'<<b;
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problemnew/solution/P1042?page=2
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problem/P1067
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problemnew/solution/P1098
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problem/P1071
|
@ -0,0 +1,39 @@
|
||||
#include<iostream>
|
||||
#include<map>
|
||||
#include<math.h>
|
||||
#include<algorithm>
|
||||
#include<string.h>
|
||||
using namespace std;
|
||||
map<char,int>m;
|
||||
int main(){
|
||||
int maxx=-999999,minn=999999;
|
||||
char a[101];
|
||||
cin>>a;
|
||||
int l=strlen(a);
|
||||
for(int i=0;i<l;i++){
|
||||
m[a[i]]++;
|
||||
maxx=max(maxx,m[a[i]]);
|
||||
//minn=min(minn,m[a[i]]);
|
||||
}
|
||||
for(int i=0;i<l;i++){
|
||||
minn=min(minn,m[a[i]]);
|
||||
}
|
||||
//cout<<maxx<<' '<<minn<<endl;
|
||||
maxx-=minn;
|
||||
// cout<<maxx<<endl;
|
||||
if(maxx==0||maxx==1){
|
||||
cout<<"No Answer"<<endl;
|
||||
cout<<0;
|
||||
return 0;
|
||||
}
|
||||
for(int i=2;i<=sqrt(maxx);i++){
|
||||
if(maxx%i==0){
|
||||
cout<<"No Answer"<<endl;
|
||||
cout<<0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
cout<<"Lucky Word"<<endl;
|
||||
cout<<maxx;
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problemnew/solution/P1125
|
@ -0,0 +1 @@
|
||||
https://blog.csdn.net/weixin_44312186/article/details/88785561
|
@ -0,0 +1,40 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
struct point {
|
||||
int x, n;//x表示要分离线所在的行或列 n指这条线能分开说话人的数量
|
||||
} y[1001], x[1001];//x是行 y为列
|
||||
bool cmp1(point a, point b) {
|
||||
return a.n > b.n;//排序时将分离数量大的放前面保证最优
|
||||
}
|
||||
|
||||
bool cmp2(point a, point b) {
|
||||
return a.x < b.x;//出答案时要求列数(行数)小的在前
|
||||
}
|
||||
|
||||
int main() {
|
||||
int m, n, k, l, d;//同题
|
||||
scanf("%d %d %d %d %d", &m, &n, &k, &l, &d);
|
||||
int x1, y1, p1, q1;//同题
|
||||
for (int i = 1; i <= d; i++) {//
|
||||
scanf("%d %d %d %d", &x1, &y1, &p1, &q1);
|
||||
if (x1 == p1) {//辨别是纵向还是横向,若横向相同则分离线为纵向
|
||||
y[min(y1, q1)].x = min(y1, q1);//标记分离线所在列数
|
||||
y[min(y1, q1)].n++;//y[min(y1,q1)].x保证相同列数分离线叠加
|
||||
}
|
||||
if (y1 == q1) {//同理
|
||||
x[min(x1, p1)].x = min(x1, p1);
|
||||
x[min(x1, p1)].n++;
|
||||
}
|
||||
}
|
||||
sort(x + 1, x + 1 + 1000, cmp1);//分离数大的在前
|
||||
sort(y + 1, y + 1 + 1000, cmp1);
|
||||
sort(x + 1, x + 1 + k, cmp2);//将答案进行整理(行数或列数小在前)
|
||||
sort(y + 1, y + 1 + l, cmp2);
|
||||
for (int i = 1; i <= k; i++)
|
||||
printf("%d ", x[i].x);
|
||||
printf("\n");//输出中间换行
|
||||
for (int i = 1; i <= l; i++)
|
||||
printf("%d ", y[i].x);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problemnew/solution/P1056?page=4
|
@ -0,0 +1,42 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
int Fun(int n)
|
||||
{
|
||||
//用数组列出0-9没一个数所需要的火柴棍数
|
||||
int arr[10] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
|
||||
int ret = 0;
|
||||
//判断n是不是两位数或更高位数
|
||||
while (n / 10 != 0){
|
||||
//将个位数所需要的火柴棍数相加
|
||||
ret += arr[n % 10];
|
||||
//更新n的个位数
|
||||
n /= 10;
|
||||
}
|
||||
//最后加上此时n需要的火柴棍数(n是一位数)
|
||||
ret += arr[n];
|
||||
return ret;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int a, b, c, m, num = 0;
|
||||
//printf("请输入火柴棍的个数\n");
|
||||
scanf("%d", &m);
|
||||
//枚举a和b
|
||||
for (a = 0; a <= 1111; a++){
|
||||
for (b = 0; b <= 1111; b++){
|
||||
c = a + b;
|
||||
//判读是否符合条件
|
||||
if (Fun(a) + Fun(b) + Fun(c) == m - 4){
|
||||
//printf("%d + %d = %d\n", a, b, c);
|
||||
//计算所有可能的个数
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//printf("一共可以拼出%d个不同等式\n", num);
|
||||
//system("pause");
|
||||
cout<<num;
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problem/P1149
|
@ -0,0 +1,17 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int a[15];
|
||||
int main() {
|
||||
int b,B,A;
|
||||
for(int i=1; i<=10; i++)
|
||||
cin>>a[i];
|
||||
cin>>b;
|
||||
B=b+30;
|
||||
int c=0;
|
||||
for(int i=1; i<=10; i++) {
|
||||
if(a[i]<=B)
|
||||
c++ ;
|
||||
}
|
||||
cout<<c;
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problem/P1046
|
@ -0,0 +1,5 @@
|
||||
树状数组 数据结构详解与模板(可能是最详细的了)
|
||||
https://blog.csdn.net/bestsort/article/details/80796531
|
||||
|
||||
树状数组入门(简单的原理讲解)
|
||||
https://www.cnblogs.com/findview/archive/2019/08/01/11281628.html
|
@ -0,0 +1,6 @@
|
||||
P1061 Jam的计数法
|
||||
https://www.luogu.org/problem/P1061
|
||||
|
||||
|
||||
ACMNO.51 JAM计数法(字母顺序之间的排列问题)
|
||||
https://blog.csdn.net/weixin_42859280/article/details/89387129
|
@ -0,0 +1,15 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main () {
|
||||
int a,b,s,max=0,i,day=0;
|
||||
for (i=1; i<8; i++) {
|
||||
cin>>a>>b;
|
||||
s=a+b;
|
||||
if ((s>max)&&(s>8)) {
|
||||
max=s;
|
||||
day=i;
|
||||
}
|
||||
}
|
||||
cout<<day;
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problem/P1085
|
@ -0,0 +1,26 @@
|
||||
#include<iostream>
|
||||
#include<stdio.h>
|
||||
using namespace std;
|
||||
int main() {
|
||||
int i,month,left=0,save=0,sum,plan,flag=0;
|
||||
for(month=1; month<=12; month++) {
|
||||
left+=300;
|
||||
scanf("%d",&plan);
|
||||
left = left - plan;
|
||||
if(left<0) {
|
||||
flag=1;
|
||||
break;
|
||||
} else {
|
||||
i = left/100;
|
||||
save += (100*i);
|
||||
left -= (100*i);
|
||||
}
|
||||
}
|
||||
if(flag>0)
|
||||
printf("-%d",month);
|
||||
else {
|
||||
sum=((1.2*save) + left);
|
||||
printf("%d",sum);
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problem/P1089
|
@ -0,0 +1 @@
|
||||
没看懂
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problem/P1246
|
@ -0,0 +1,3 @@
|
||||
https://www.luogu.org/problem/P1086
|
||||
|
||||
https://www.luogu.org/problemnew/solution/P1086?page=7
|
@ -0,0 +1,29 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n,score1,score2,sum=0,max=0,total=0,x,i;
|
||||
char a,b;
|
||||
string name,maxn;
|
||||
cin>>n;
|
||||
for(i=1;i<=n;i++)
|
||||
{
|
||||
cin>>name>>score1>>score2>>a>>b>>x;
|
||||
if(score1>80 && x>0)//判断是否获得院士奖学金
|
||||
sum+=8000;
|
||||
if(score1>85 && score2>80)//判断是否获得五四奖学金
|
||||
sum+=4000;
|
||||
if(score1>90)//判断是否获得成绩优秀奖
|
||||
sum+=2000;
|
||||
if(score1>85 && b=='Y')//判断是否获得西部奖学金
|
||||
sum+=1000;
|
||||
if(score2>80 && a=='Y')//判断是否获得班级贡献奖
|
||||
sum+=850;
|
||||
total+=sum;//累加奖学金
|
||||
if(sum>max)//找出最牛学生
|
||||
maxn=name,max=sum;//sum的用处
|
||||
sum=0;
|
||||
}
|
||||
cout<<maxn<<endl<<max<<endl<<total;
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problem/P1051
|
@ -0,0 +1,7 @@
|
||||
https://www.cnblogs.com/five20/p/7534747.html
|
||||
|
||||
信息学竞赛刷题建议历程
|
||||
https://blog.csdn.net/cnyali/article/details/41688175
|
||||
|
||||
省一,洛谷题要刷到哪种阶段?
|
||||
https://www.zhihu.com/question/296752963?sort=created
|
@ -0,0 +1,16 @@
|
||||
【鱼同学的算法讲堂】数据结构专题之线段树基础
|
||||
https://www.bilibili.com/video/av37703183/?redirectFrom=h5
|
||||
|
||||
|
||||
线段树入门
|
||||
https://www.bilibili.com/video/av40667689/?spm_id_from=333.788.videocard.4
|
||||
|
||||
菜鸟都能理解的线段树入门经典
|
||||
https://blog.csdn.net/ray_seu/article/details/8705640
|
||||
|
||||
|
||||
线段树--从入门到入土
|
||||
https://www.cnblogs.com/rmy020718/p/9571490.html
|
||||
|
||||
线段树(超基础版)
|
||||
https://www.bilibili.com/video/av47446422/
|
@ -0,0 +1,9 @@
|
||||
树状数组
|
||||
https://blog.csdn.net/bestsort/article/details/80796531#main-toc
|
||||
|
||||
|
||||
区间修改 单点查询
|
||||
|
||||
差分
|
||||
|
||||
为什么不用线段树?因为常数大,可能跑不过?
|
@ -0,0 +1,86 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
struct Line {
|
||||
int left, right, count;
|
||||
Line *leftChild, *rightChild;
|
||||
Line(int l, int r): left(l), right(r) {}
|
||||
};
|
||||
|
||||
//建立一棵空线段树
|
||||
void createTree(Line *root) {
|
||||
int left = root->left;
|
||||
int right = root->right;
|
||||
if (left < right) {
|
||||
int mid = (left + right) / 2;
|
||||
Line *lc = new Line(left, mid);
|
||||
Line *rc = new Line(mid + 1, right);
|
||||
root->leftChild = lc;
|
||||
root->rightChild = rc;
|
||||
createTree(lc);
|
||||
createTree(rc);
|
||||
}
|
||||
}
|
||||
|
||||
//将线段[l, r]分割
|
||||
void insertLine(Line *root, int l, int r) {
|
||||
cout << l << " " << r << endl;
|
||||
cout << root->left << " " << root->right << endl << endl;
|
||||
if (l == root->left && r == root->right) {
|
||||
root->count += 1;
|
||||
} else if (l <= r) {
|
||||
int rmid = (root->left + root->right) / 2;
|
||||
if (r <= rmid) {
|
||||
insertLine(root->leftChild, l, r);
|
||||
} else if (l >= rmid + 1) {
|
||||
insertLine(root->rightChild, l, r);
|
||||
} else {
|
||||
int mid = (l + r) / 2;
|
||||
insertLine(root->leftChild, l, mid);
|
||||
insertLine(root->rightChild, mid + 1, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
//树的中序遍历(测试用)
|
||||
void inOrder(Line* root) {
|
||||
if (root != NULL) {
|
||||
inOrder(root->leftChild);
|
||||
printf("[%d, %d], %d\n", root->left, root->right, root->count);
|
||||
inOrder(root->rightChild);
|
||||
}
|
||||
}
|
||||
|
||||
//获取值n在线段上出现的次数
|
||||
int getCount(Line* root, int n) {
|
||||
int c = 0;
|
||||
if (root->left <= n&&n <= root->right)
|
||||
c += root->count;
|
||||
if (root->left == root->right)
|
||||
return c;
|
||||
int mid = (root->left + root->right) / 2;
|
||||
if (n <= mid)
|
||||
c += getCount(root->leftChild, n);
|
||||
else
|
||||
c += getCount(root->rightChild, n);
|
||||
return c;
|
||||
}
|
||||
int main() {
|
||||
int l[3] = {2, 4, 0};
|
||||
int r[3] = {5, 6, 7};
|
||||
int MIN = l[0];
|
||||
int MAX = r[0];
|
||||
for (int i = 1; i < 3; ++i) {
|
||||
if (MIN > l[i]) MIN = l[i];
|
||||
if (MAX < r[i]) MAX = r[i];
|
||||
}
|
||||
Line *root = new Line(MIN, MAX);
|
||||
createTree(root);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
insertLine(root, l[i], r[i]);
|
||||
}
|
||||
inOrder(root);
|
||||
int N;
|
||||
while (cin >> N) {
|
||||
cout << getCount(root, N) << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int n,x,ans;
|
||||
priority_queue<int,vector<int>,greater<int> >q;
|
||||
int main(){
|
||||
cin>>n;
|
||||
for(int i=1;i<=n;i++) cin>>x,q.push(x);
|
||||
while(q.size()>=2){
|
||||
int a=q.top(); q.pop();
|
||||
int b=q.top(); q.pop();
|
||||
ans+=a+b;
|
||||
q.push(a+b);
|
||||
}
|
||||
cout<<ans<<endl;
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problem/P1090
|
@ -0,0 +1 @@
|
||||
https://www.luogu.org/problem/P1016
|
@ -0,0 +1 @@
|
||||
https://blog.csdn.net/largecub233/article/details/68923039
|
@ -0,0 +1,26 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main() {
|
||||
int N;
|
||||
cin>>N;
|
||||
int a[N] = {0};
|
||||
for(int i=0;i<N;i++)
|
||||
{
|
||||
cin>>a[i];
|
||||
}
|
||||
sort(a, a + N, less<int>() );
|
||||
|
||||
int n = unique(a, a + N) - a;
|
||||
|
||||
cout<<n<<endl;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
cout << a[i] << " ";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Binary file not shown.
@ -0,0 +1,30 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main() {
|
||||
set<int>s;
|
||||
int n;
|
||||
cin>>n;
|
||||
for(int i=1; i<=n; i++) {
|
||||
int x;
|
||||
cin>>x;
|
||||
s.insert (x);
|
||||
}
|
||||
set<int>::iterator it;
|
||||
for(it=s.begin (); it!=s.end (); it++) {
|
||||
printf("%d\n",*it);
|
||||
}
|
||||
|
||||
//s.end()没有值
|
||||
cout<<"s.begin() "<<*s.begin ()<<endl;
|
||||
//lower_bound()--返回指向大于(或等于)某值的第一个元素的迭代器
|
||||
cout<<"lower_buond 3 "<<*s.lower_bound (3)<<endl;
|
||||
|
||||
//upper_bound()--返回大于某个值元素的迭代器
|
||||
cout<<"upper_bound 3 "<<*s.upper_bound (3)<<endl;
|
||||
|
||||
//find()--返回一个指向被查找到元素的迭代器
|
||||
cout<<"find() 3 "<<*s.find (3)<<endl;
|
||||
|
||||
cout<<"s.size() "<<s.size ()<<endl;
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int a[] = {1,2,3};
|
||||
set<int> s(a,a+3);
|
||||
set<int>::iterator iter;
|
||||
if((iter = s.find(2)) != s.end())
|
||||
{
|
||||
cout<<*iter<<endl;//输出为2
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main() {
|
||||
int a[] = {1,2,3};
|
||||
set<int> s;
|
||||
set<int>::iterator iter;
|
||||
s.insert(a,a+3);
|
||||
for(iter = s.begin() ; iter != s.end() ; ++iter) {
|
||||
cout<<*iter<<" ";
|
||||
}
|
||||
cout<<endl;
|
||||
pair<set<int>::iterator,bool> pr;
|
||||
pr = s.insert(5);
|
||||
if(pr.second) {
|
||||
cout<<*pr.first<<endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
After Width: | Height: | Size: 132 KiB |
After Width: | Height: | Size: 81 KiB |
@ -0,0 +1,56 @@
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
//全排列代码说明
|
||||
|
||||
// https://www.jianshu.com/p/e0de4c9b73f2?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation
|
||||
|
||||
using namespace std;
|
||||
|
||||
//在[from, to]区间中是否有字符与下标为from的字符相等
|
||||
bool IsSwap(char* from, char* to)
|
||||
{
|
||||
char* p;
|
||||
for(p = from; p < to; p++)
|
||||
{
|
||||
if(*p == *to)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AllPermutation(char* perm, int from, int to)
|
||||
{
|
||||
if(from > to)
|
||||
return;
|
||||
|
||||
if(from == to) //打印当前排列
|
||||
{
|
||||
static int count = 1; //局部静态变量,用来统计全排列的个数
|
||||
cout << count++ << ":" << perm;
|
||||
cout << endl;
|
||||
}
|
||||
if(from < to) //用递归实现全排列
|
||||
{
|
||||
for(int j = from; j <= to; j++) //第j个字符分别与它后面的字符交换就能得到新的排列
|
||||
{
|
||||
if(IsSwap((perm + j), (perm + to)))
|
||||
{
|
||||
swap(perm[j], perm[from]);
|
||||
//cout<<0;
|
||||
AllPermutation(perm, from + 1, to);
|
||||
//cout<<1;
|
||||
swap(perm[j], perm[from]);
|
||||
//cout<<2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char str[100];
|
||||
cin >> str;
|
||||
AllPermutation(str, 0, strlen(str) - 1);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main() {
|
||||
//注意:这个数组的数字要先排好顺序,由小到大,否则只输出比现在大的全排列!
|
||||
int num[5]= {3,1,2,4,5};
|
||||
//快速排序
|
||||
sort(num, num+5);
|
||||
//输出全排列
|
||||
do {
|
||||
cout<<num[0]<<" "<<num[1]<<" "<<num[2]<<" "<<num[3]<<" "<<num[4]<<endl;
|
||||
} while(next_permutation(num,num+5));
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
//C++STL中全排列函数next_permutation的使用
|
||||
// https://blog.csdn.net/ac_gibson/article/details/45308645
|
||||
int main()
|
||||
{
|
||||
int a[3] = { 3,1,2 };
|
||||
|
||||
//快速排序
|
||||
sort(a, a + 3);
|
||||
|
||||
//全排列
|
||||
do
|
||||
{
|
||||
cout << a[0] << a[1] << a[2] << endl;
|
||||
} while (next_permutation(a, a + 3));
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,158 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="DFS实现全排列.cpp" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{26EB7DDD-AA76-44F3-8780-67869B7CF8DD}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>ShjCppStudy</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="DFS实现全排列.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>true</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -0,0 +1,39 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
//打印数组全部元素
|
||||
void prt(int arr[], int end) {
|
||||
for (int i = 0; i <= end; ++i) {
|
||||
printf("%d", arr[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
//全排列 c++实现
|
||||
//https://blog.csdn.net/u013309870/article/details/68941284
|
||||
//https://blog.csdn.net/jiaobuchong/article/details/85369970
|
||||
|
||||
//https://www.cnblogs.com/kiritozhj/p/10501470.html
|
||||
// https://blog.csdn.net/sofia_m/article/details/78865892
|
||||
|
||||
void perm(int arr[], int begin, int end) {
|
||||
//递归出口,结束时打印结果
|
||||
if (begin == end) {
|
||||
prt(arr, end);
|
||||
return;
|
||||
}
|
||||
//还没到出口时,就需要进行递归的递归体开发
|
||||
for (int i = begin; i <= end; ++i) {
|
||||
//交换两个元素值
|
||||
swap(arr[begin], arr[i]);
|
||||
//递归体
|
||||
perm(arr, begin + 1, end);
|
||||
//恢复原状
|
||||
swap(arr[begin], arr[i]);
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int arr[3] = { 3,1,2 };
|
||||
perm(arr, 0, 2);
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
//打印数组全部元素
|
||||
void prt(int arr[], int end) {
|
||||
for (int i = 0; i <= end; ++i) {
|
||||
printf("%d", arr[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void perm(int arr[], int len) {
|
||||
if (len < 2) return;
|
||||
int i, j, temp;
|
||||
while(1) {
|
||||
//输出当前序列
|
||||
prt(arr, len - 1);
|
||||
i = j = len - 1;
|
||||
//向前查找第一个变小的元素
|
||||
while (i > 0 && arr[i] < arr[i - 1]) --i;
|
||||
temp = i;
|
||||
if (i == 0) break;
|
||||
//先后查找第一个比arr[i-1]大的元素
|
||||
while (temp + 1 < len && arr[temp + 1] > arr[i - 1]) ++temp;
|
||||
swap(arr[i - 1], arr[temp]); //交换两个值
|
||||
reverse(arr + i, arr + len); //逆序
|
||||
};
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int arr[3] = { 3,1,2 };
|
||||
//快速排序
|
||||
sort(arr, arr + 3);
|
||||
//输出全排列
|
||||
perm(arr,3);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue