2024-2-27-1227-分巧克力.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=100010;

int n,k;
int h[N],w[N];
bool check(int mid)
{
int res=0;
for(int i=0;i<n;i++)
{
res+=(h[i]/mid)*(w[i]/mid);if(res>=k) return true;
}

return false;
}

int main(){
cin>>n>>k;
for(int i=0;i<n;i++)
{
scanf("%d%d",&h[i],&w[i]);
}
int l=1,r=1e5;
while(l<r)
{
int mid=(l+r+1)>>1;
if(check(mid)) l=mid;
else r=mid-1;
}
printf("%d\n",l);
return 0;
}

2024-2-27-1221-四平方和-哈希表版本.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include <unordered_map>
using namespace std;
#define x first
#define y second
typedef pair<int,int> PII;
const int N=2500010;
struct sum{
int s,c,d;
bool operator< (const sum &t)const
{
if(s!=t.s)return s<t.s;
if(s!=t.c)return c<t.c;
return d<t.s;
}
}sum[N];
int n,m;
unordered_map<int, PII> S;
int main() //二分版本
{
cin>>n;
for(int c=0;c*c<=n;c++)
for(int d=c;c*c+d*d<=n;d++)
{ int t=c*c+d*d;
if(S.count(t)==0)S[t]={c,d};
}

for(int a=0;a*a<=n;a++)
for(int b=a;b*b+a*a<=n;b++)
{
int t=n-a*a-b*b;
if(S.count(t))
{
printf("%d %d %d %d\n",a,b,S[t].x,S[t].y );
return 0;
}
}
return 0;
}

2024-2-27-1221-四平方和-二分版本.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
const int N=2500010;
struct sum{
int s,c,d;
bool operator< (const sum &t)const
{
if(s!=t.s)return s<t.s;
if(s!=t.c)return c<t.c;
return d<t.s;
}
}sum[N];
int n,m;
int q[N];
int main() //二分版本
{
cin>>n;
for(int c=0;c*c<=n;c++)
for(int d=c;c*c+d*d<=n;d++)
sum[m++]={c*c+d*d,c,d};
sort(sum,sum+m);
for(int a=0;a*a<=n;a++)
for(int b=a;b*b+a*a<=n;b++)
{
int t=n-a*a-b*b;
int l=0,r=m;
while(r>l)
{int mid=(r+l)>>1;
if(sum[mid].s>=t)
r=mid;
else l=mid+1;

}
if(sum[l].s==t)
{
printf("%d %d %d %d\n",a,b,sum[l].c,sum[l].d);
return 0;
}
}
return 0;
}



2024-2-27-730飞行员兄弟.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100010;
int n;
int h[N];

bool check(int e)
{
for(int i=1;i<=n;i++)
{
e=e*2-h[i];
if(e>=1e5)
return true;
if(e<0) return 0;
}
return true;
}

int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&h[i]);
int l=0,r=1e5;
while(r>l){
int mid=l+r>>1;
if(check(mid))
r=mid;
else l=mid+1;
}
printf("%d\n",l);
return 0;
}

1.胆识
2.投资自己的智慧,向成功者借智慧
3.学习英语,必须是按照“听、说、读、写、译”的顺序,就像我们小孩子在会讲话前,肯定是先能听清爸爸妈妈的讲话,才能进行模仿,然后才能讲话。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*********************************************************************
程序名:
版权:
作者: 蔡6
日期: 2023-12-14 15:15
说明: cai6.love
*********************************************************************/
#include <iostream>
using namespace std;
#define ok 1
#define error 0
#define true 1
#define false 0
#define maxsize 20
typedef int elemtype;


typedef struct {
elemtype date[maxsize];
int length;
} SqList;

typedef int Status;//Status为函数返回状态

/* 初始化顺序线性表 */
Status InitList(SqList *L) {
L->length = 0;
return ok;
}

Status visit(elemtype c) { //查看数据
cout << c;
return ok;
}

Status InstEmpty(SqList L) {
if (L.length == 0)
return true;
else
return false;

}

Status ClearList(SqList *L) { //需要对其进行修改则使用指针,或者引用&
L->length = 0;
return ok;
}

Status GetElen(SqList *L, int i, elemtype *e) { //获取第i位元素,并将其赋值给e
if (L->length == 0 || i < 1 || i > L->length)
return error;
*e = L->date[i - 1];
return ok;
}

Status ListInsert(SqList *L, int i, elemtype e) {
//对线性表的第i位进行插入e
if (L->length == maxsize )
return error;
if ( i < 1 || i > L->length + 1)
return error;
if (i <= L->length) {
for (int k = L->length - 1; k >= i - 1; k--)
L->date[k + 1] = L->date[k];
}
L->date[i - 1] = e;
L->length++;


return ok;
}


Status ListDelete(SqList *L, int i) {
if ( i < 1 || i > L->length + 1)
return error;
if (i <= L->length) {
for (int k = L->length - 2; k >= i - 1; k--)
L->date[k] = L->date[k + 1];
}
L->length--;


return ok;

}

/* 初始条件:顺序线性表L已存在。操作结果:返回L中数据元素个数 */
int ListLength(SqList L) {
return L.length;
}

Status ListTraverse(SqList L) { //依次输出全部数据
for (int i = 0; i < L.length; i++) {
cout << L.date[i] << endl;
}
return ok;
}

int main() {
Status i;
SqList L;
i = InitList(&L);
printf("初始化L后:L.length=%d\n", L.length);
int a = 2;
i = ListInsert(&L, 1, a);
i = ListInsert(&L, 1, 5);
i = ListTraverse(L);
i = ListDelete(&L, 2);
i = ListTraverse(L);
return 0;
}

完成netlify拉取,利用dns进行加速,已将github库设置为private

完成hexo基础搭建

1.全局音乐播放器搭建完毕
2.living-2d搭建完毕
3.本地端后台搭建完毕

算法竞赛入门经典3-2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
2023-12-02 10:35 

/***
* _ooOoo_
* o8888888o
* 88" . "88
* (| -_- |)
* O\ = /O
* ____/`---'\____
* . ' \\| |// `.
* / \\||| : |||// \
* / _||||| -:- |||||- \
* | | \\\ - /// | |
* | \_| ''\---/'' | |
* \ .-\__ `-` ___/-. /
* ___`. .' /--.--\ `. . __
* ."" '< `.___\_<|>_/___.' >'"".
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
* \ \ `-. \_ __\ /__ _/ .-` / /
* ======`-.____`-.___\_____/___.-`____.-'======
* `=---='
*
* .............................................
* 佛祖保佑 永无BUG
*/


/***
* http://www.flvcd.com/
* .--, .--,
* ( ( \.---./ ) )
* '.__/o o\__.'
* {= ^ =}
* > - <
* / \
* // \\
* //| . |\\
* "'\ /'"_.-~^`'-.
* \ _ /--' `
* ___)( )(___
* (((__) (__))) 高山仰止,景行行止.虽不能至,心向往之。
*/


#include <iostream>
#include <string.h>
using namespace std;

int a[1005], n, k;
// If this comment is removed the program will blow up
// 如果删了此处注释程序就炸了

int main() {
memset(a, 0, sizeof(a)); //将a置0,需包含<string.h>
cin >> n >> k;
for (int i = 1; i <= k; i++) {
for (int j = 1; j <= n; j++) {
if (j % i == 0) {
a[j] = !a[j];
}
}
}
int first = 1;
for (int i = 1; i <= n; i++)
if (a[i]) {
cout << " " << i;
}
cout << endl;

return 0;
}

0%