This commit is contained in:
HuangHai
2025-08-30 18:35:01 +08:00
commit 1f397eca87
6258 changed files with 1487241 additions and 0 deletions

Binary file not shown.

View File

@@ -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;
}

View File

@@ -0,0 +1,2 @@
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬѧ<EFBFBD><EFBFBD><EFBFBD>㷨<EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ
https://www.bilibili.com/video/av39988212

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 KiB

View File

@@ -0,0 +1,25 @@
#include<bits/stdc++.h>**//万能头文件
using namespace std;//流操作命名空间
//递归
string dfs(int n){
//返回处理后的字符,一直递归直至全部处理完(0,1,2必须特判跳出);
string out="";//存储输出
int k=-1,i=1;bool ff[16];//临时变量;
//
for(int i=0;i<=15;i++){
ff[i]=n&1;n=n>>1;//二进制取位运算,取得所有的为1的二进位表示可以操作
}
for(int i=15;i>=0;i--){
if(ff[i]){//判断是否为1
if(i>=2)out+="2(" + dfs(i) + ")+";//二以上则再次递归指数
if(i==1)out+="2+";//特判1
if(i==0)out+="2(0)+";//特判0
}
}
return out.substr(0,out.size()-1);//返回//去除尾部‘+’
}
int main(){
int n;cin>>n;
cout<<dfs(n);
return 0;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problem/P1010

View File

@@ -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;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problem/P1055#submit

View File

@@ -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;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problemnew/solution/P1042?page=2

View File

@@ -0,0 +1,19 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,a,i;
cin>>n;
for(i=n; i>=0; i--) {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>x<EFBFBD>ļ<EFBFBD><C4BC>η<EFBFBD>
cin>>a;
if(a) { //<2F>ж<EFBFBD>a<EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD>棨<EFBFBD><E6A3A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>
if(i!=n&&a>0) cout<<"+"; //i<><69>=n<><6E><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>
if(abs(a)>1||i==0) cout<<a;//abs<62>Ǿ<EFBFBD><C7BE><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-1<><31>1ʱ<31><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(a==-1&&i) cout<<"-"; //-1ʡ<31><CAA1>1
if(i>1) cout<<"x^"<<i;
if(i==1) cout<<"x"; //ָ<><D6B8>Ϊ1ʱʡ<CAB1><CAA1>1
}
}
return 0;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problem/P1067

View File

@@ -0,0 +1,24 @@
#include<bits/stdc++.h>
using namespace std;
int p1,p2,p3,i=0,k;
char ch[300],be,af,f,j,p;//p用于输出;
int main() {
scanf("%d%d%d%s",&p1,&p2,&p3,ch);//输入;
while(ch[i]){//当ch[i]有值时;
be=ch[i-1];af=ch[i+1];f=ch[i];//f存储ch[i],便于判断;
if(f=='-'&&af>be&&(be>='0'&&af<='9'||be>='a'&&af<='z')){//意思是ch[i]若为'-',就判断其前后是否满足条件,满足进入循环;
for(p3==1?j=be+1:j=af-1; p3==1?j<af:j>be; p3==1?j++:j--){
p=j;//j是整形变量,p是字符型变量,这样是将p赋值为ASCII码为j的字符;
if(p1==2)//是否大写;
p=(p>='a')?p-32:p;//如果是字母就转成大写
else if(p1==3) p='*';//是否输出'*'
for(k=0; k<p2; k++)//输出p2个
printf("%c",p);
}
}
else
printf("%c",f);//如果ch[i]是非'-'或者其前后不满足条件,就原样输出;
i++;//一定要放在后面,不然会出错QAQ;
}
return 0;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problemnew/solution/P1098

View File

@@ -0,0 +1,50 @@
#include<bits/stdc++.h>
using namespace std;
map<char,char>m0,m1; //m0记录密文对明文,m1记录明文对密文
char miwen[10000],mingwen[10000],target[10000];
int main()
{
gets(miwen);//输入密文
gets(mingwen);//输入明文
gets(target);//输入要翻译的信息
//第一个for循环用来记录明文和密文的对应关系
for(int i=0;i<strlen(miwen);i++)
{
//判断密文多对一,或明文多对一的情况,如果符合这种情况,说明和规则不符,直接输出Failed
if((m0.count(miwen[i]) && m0[miwen[i]]!=mingwen[i]) || (m1.count(mingwen[i]) && m1[mingwen[i]]!=miwen[i]))
{
cout<<"Failed";
return 0;
}
//如果符合规则,则记录
else
{
m0[miwen[i]]=mingwen[i];
m1[mingwen[i]]=miwen[i];
}
}
//第二个for循环用来判断是否符合第一条规则,即A~Z全部有对应的密文
char temp='A';
for(int i=0;i<26;i++)
{
//判断是否A~Z都有密文,如果发现没有密文的,说明和规则不符,直接输出Failed
if(!m1.count(temp+i))
{
cout<<"Failed";
return 0;
}
}
//如果运行到了这里,说明所有规则都符合。直接第三个for循环输出结果
for(int i=0;i<strlen(target);i++)
{
if(target[i]!=' ')//注意输入的翻译信息行末有空格!!
cout<<m0[target[i]];
}
return 0;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problem/P1071

View File

@@ -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;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problemnew/solution/P1125

View File

@@ -0,0 +1 @@
https://blog.csdn.net/weixin_44312186/article/details/88785561

View File

@@ -0,0 +1,27 @@
#include<bits/stdc++.h>
#define maxn 1000
using namespace std;
int dp[maxn];
int main() {
int n;
scanf("%d", &n);
int a[maxn];
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
dp[0] = a[0];//边界 (结果总是确定的,动态规划总是从这些边界出发)
for (int i = 0; i < n; i++) {
dp[i] = max(a[i], dp[i - 1] + a[i]);//递推式
}
//dp[i]存放以a[i]结尾的连续序列的最大和,需要遍历i得到最大的才是结果
int k = 0;
for (int i = 0; i < n; i++) {
if (dp[i] > dp[k]) {
k = i;
}
}
printf("%d\n", dp[k]);
return 0;
}

View File

@@ -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;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problemnew/solution/P1056?page=4

View File

@@ -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;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problem/P1149

View File

@@ -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;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problem/P1046

View File

@@ -0,0 +1,5 @@
<EFBFBD><EFBFBD>״<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ݽṹ<DDBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD>)
https://blog.csdn.net/bestsort/article/details/80796531
<EFBFBD><EFBFBD>״<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28>򵥵<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
https://www.cnblogs.com/findview/archive/2019/08/01/11281628.html

View File

@@ -0,0 +1,39 @@
#include <iostream>
using namespace std;
int main()
{
char ch[26],l,r;
int w,i,k,j;
cin>>i>>j>>w;
l=i+'a'-1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ
r=j+'a'-1;
cin>>ch;
for(i=1;i<=5;i++)
{
j=w-1; //<2F><>'<27><>λ'<27><>ʼ<EFBFBD><CABC>
cout<<"<EFBFBD><EFBFBD>'<27><>λ'<27><>ʼ<EFBFBD><CABC> i<><69><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>"<<i<<endl;
//------------------------------------------------<2D><>
while(j>=0&&ch[j]==r+j+1-w)
{
printf("%c ",r+j+1-w);
cout<<ch[j]<<" "<<"ttt<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>j<EFBFBD><EFBFBD>"<<j<<" <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ch<63><68>"<<ch<<endl;
j--; //<2F>ҵ<EFBFBD><D2B5><EFBFBD>ǰΪ<C7B0>˰<EFBFBD><CBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>С<EFBFBD><D0A1><EFBFBD><EFBFBD>
}
if(j==-1)
break;
//------------------------------------------------<2D><>
cout<<"yuanlai<EFBFBD><EFBFBD>"<<ch[j];
ch[j]++; //<2F><>λ
cout<<"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>"<<ch[j]<<endl;
for (k=j+1;k<=w-1;k++)
ch[k]=ch[k-1]+1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ֮<CEBB><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cout<<ch<<endl;
}
return 0;
}
/*
<EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD>1<2<3<4...
<EFBFBD><EFBFBD>Jam<EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a>b>c>d...
*/

View File

@@ -0,0 +1,6 @@
P1061 Jam<61>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
https://www.luogu.org/problem/P1061
ACMNO.51 JAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>ĸ˳<C4B8><CBB3>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
https://blog.csdn.net/weixin_42859280/article/details/89387129

View File

@@ -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;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problem/P1085

View File

@@ -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;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problem/P1089

View File

@@ -0,0 +1 @@
û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>

View File

@@ -0,0 +1 @@
https://www.luogu.org/problem/P1246

View File

@@ -0,0 +1,46 @@
#include<iostream>
#include<queue>
#include<cmath>
using namespace std;
struct hs //指花生:)
{
int x, y, v;
bool operator < (const hs & a) const
{
return v < a.v;
}//优先队列默认从大到小排序,但是需要用到小于号,所以这里重载运算符 < (只重载<就可以了)
};
priority_queue <hs> q;
int main()
{
int m, n, k;
int sum = 0;
cin >> m >> n >> k;
int a;
hs t;
for(int i = 1; i <= m; i++)
for(int j = 1; j <= n; j++)
{
cin >> a;
t.v = a;
t.x = j;
t.y = i;
if(a != 0) //如果有数值,就推进队列
q.push(t);
}
k -= q.top().y; //走到最大的花生植株
while(!q.empty() && k > q.top().y) //第一个是检验队列不为空,如果空了说明全摘完了,第二个是检验剩余的时间可以走回路边
{
k--; //只要进入一次循环,说明到了一棵植株,采摘耗费1时间
sum += q.top().v;
int lx = q.top().x, ly = q.top().y;
q.pop();//换下一棵树
k -= abs(lx - q.top().x) + abs(ly - q.top().y);//剩余的时间减去从上一棵植株到这棵的时间
}
cout << sum << endl;
return 0;
}

View File

@@ -0,0 +1,3 @@
https://www.luogu.org/problem/P1086
https://www.luogu.org/problemnew/solution/P1086?page=7

View File

@@ -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;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problem/P1051

View File

@@ -0,0 +1,7 @@
https://www.cnblogs.com/five20/p/7534747.html
<EFBFBD><EFBFBD>Ϣѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ<EFBFBD>⽨<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
https://blog.csdn.net/cnyali/article/details/41688175
ʡһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫˢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ׶Σ<EFBFBD>
https://www.zhihu.com/question/296752963?sort=created

View File

@@ -0,0 +1,16 @@
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬѧ<EFBFBD><EFBFBD><EFBFBD>㷨<EFBFBD><EFBFBD><EFBFBD>á<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹר<EFBFBD><EFBFBD>֮<EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
https://www.bilibili.com/video/av37703183/?redirectFrom=h5
<EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
https://www.bilibili.com/video/av40667689/?spm_id_from=333.788.videocard.4
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ž<EFBFBD><EFBFBD><EFBFBD>
https://blog.csdn.net/ray_seu/article/details/8705640
<EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD>--<2D><><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>
https://www.cnblogs.com/rmy020718/p/9571490.html
<EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>棩
https://www.bilibili.com/video/av47446422/

View File

@@ -0,0 +1,9 @@
树状数组
https://blog.csdn.net/bestsort/article/details/80796531#main-toc
区间修改 单点查询
差分
为什么不用线段树?因为常数大,可能跑不过?

View File

@@ -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) {}
};
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD>ÿ<EFBFBD><C3BF>߶<EFBFBD><DFB6><EFBFBD>
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);
}
}
//<2F><><EFBFBD>߶<EFBFBD>[l, r]<5D>ָ<EFBFBD>
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);
}
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>
void inOrder(Line* root) {
if (root != NULL) {
inOrder(root->leftChild);
printf("[%d, %d], %d\n", root->left, root->right, root->count);
inOrder(root->rightChild);
}
}
//<2F><>ȡֵn<D6B5><6E><EFBFBD>߶<EFBFBD><DFB6>ϳ<EFBFBD><CFB3>ֵĴ<D6B5><C4B4><EFBFBD>
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;
}

View File

@@ -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;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problem/P1090

View File

@@ -0,0 +1,63 @@
#include<bits/stdc++.h>
using namespace std;
double maxx,mo=0,d2,temlen=0,d1,c,p;
//temlen:油箱中在到达了下一个加油站时油箱中的剩余油量可以继续走的路程
int n;
struct add
{
double co;
double dis;
}pl[10000];//加油站结构体:dis-距离起点的距离,co:油价
int move(int now)//1.now:现在到达的加油站
{
int can=99999;
int f=pl[now].dis;
for(int i=now+1;i<=n&&pl[i].dis-f<=maxx;i++)
{
if(pl[i].co<pl[now].co)//2.
{
mo+=((pl[i].dis-f-temlen)/d2)*pl[now].co;
temlen=0;
return i;
}
if(can==99999||pl[i].co<pl[can].co)can=i;
}
if(d1-pl[now].dis<=maxx)
{
mo+=((d1-pl[now].dis-temlen)/d2)*pl[now].co;
return 9999;
}
if(can==99999)//4.
{
cout<<"No Solution";
return -1;
}
else//3.
{
mo+=c*pl[now].co;
temlen+=(maxx-pl[can].dis+f);
return can;
}
}
int cmp(add a,add b)
{
return a.dis<b.dis;
}
int main()
{
cin>>d1>>c>>d2>>p>>n;
pl[0].dis=0;
pl[0].co=p;
for(int i=1;i<=n;i++)cin>>pl[i].dis>>pl[i].co;
sort(pl,pl+n,cmp);
maxx=c*d2;
int k=0,t;
do
{
t=move(k);
k=t;
if(t==-1)return 0;
}while(t!=9999);
printf("%.2f",mo);
return 0;
}

View File

@@ -0,0 +1 @@
https://www.luogu.org/problem/P1016

View File

@@ -0,0 +1 @@
https://blog.csdn.net/largecub233/article/details/68923039