Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ghjgjgj #890

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,301 changes: 1,301 additions & 0 deletions lanqiao/刘东升/题解1/题解.md

Large diffs are not rendered by default.

195 changes: 195 additions & 0 deletions lanqiao/刘东升/题解1/题解第七届.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@


### 网友年龄

```c++
#include<bits/stdc++.h>
using namespace std;
int main()
{
int i,ans=0;
for(i=10;i<=99;i++)
{
int middle=i;
int ge=middle%10;
middle=middle/10;
middle=middle+ge*10;
if(middle+27==i)
{
ans++;
}
}
cout<<ans;
}
```

### 生日蜡烛

```c++
#include<bits/stdc++.h>
using namespace std;
int main()
{
int c=236;
c*=2;
for(int i=1;i<=100;i++)
{
for(int j=i+1;j<=100;j++)
{
if((i+j)*(j-i+1)==c)
{
cout<<i;
}
}
}

}
```

方格填数

```c++
#include<stdio.h>
#include<math.h>
int ans = 0;
int my_arr[10] = { 0 };
int arr[10] = { 0 };
int visit[3][4] = { 0 };
int count = 0;
int dir[8][2] = { 0, -1, 0, 1, 1, 0, -1, 0, 1, 1, 1, -1, -1, -1, -1, 1 };
int judge(const int x,const int y)
{
int i = 0;
int tx = 0;
int ty = 0;
for (i = 0; i < 8; i++)
{
tx = x + dir[i][0];
ty = y + dir[i][1];
if ((tx<0) || (tx>2) || (ty<0) || (ty>3))
{
continue;
}
if (visit[tx][ty] == -10)
{
continue;
}
if (abs(visit[tx][ty] - visit[x][y] == 1))
{
return 0;
}
}
return 1;
}
void slove()
{
int i = 0;
int j = 0;
int n = 0;
for (i = 0; i < 3; i++)
{
for (j = 0; j < 4; j++)
{
if ((i == 0 && j == 0) || (i == 2 && j == 3))
{
visit[i][j] = -10;
}
else
{
visit[i][j] = arr[n];
n++;
}
}
}
for (i = 0; i < 3; i++)
{
for (j = 0; j < 4; j++)
{
if ((i == 0 && j == 0) || (i == 2 && j == 3))
{
continue;
}
else
{
if (!judge(i,j))
{
return;
}
}
}
}
ans++;
}
void dfs(int index)
{
if (index == 10)
{
slove();
return;
}
else
{
int i = 0;
for (i = 0; i <= 9; i++)
{
if (!my_arr[i])
{
my_arr[i] = 1;
arr[count] = i;
count++;
dfs(index + 1);
arr[count] = 0;
count--;
my_arr[i] = 0;
}
}
}
}
int main()
{
dfs(0);
printf("%d", ans);
return 0;
}
```



### 1

```c++

```



### 1

```c++

```



### 1

```c++

```



### 1

```c++

```



### 1

```c++

```

15 changes: 15 additions & 0 deletions winter-day5/刘东升/7-1 相邻数对.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,cnt=0;
int a[1000];
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
if(abs(a[i]-a[j])==1)
cnt++;
cout<<cnt;
}
47 changes: 47 additions & 0 deletions winter-day5/刘东升/7-3 两个有序序列的中位数.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include<bits/stdc++.h>
using namespace std;
int cnt=0;
int n;
int arr[200005];
int a[100005];
int b[100005];
int main()
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
cin>>b[i];
}
int p,q;
p=q=0;
for(int i=0;i<n*2;i++)
{
if(a[p]<=b[q]&&p<n)
{
arr[i]=a[p];
p++;
}
else if(a[p]>b[q]&&q<n)
{
arr[i]=b[q];
q++;
}
else if(p>=n&&q<n)
{
arr[i]=b[q];
q++;
}
else if(p<n&&q>=n)
{
arr[i]=a[p];
p++;
}
}
int t=(n*2-1)/2;
cout<<arr[t];
return 0;
}
45 changes: 45 additions & 0 deletions winter-day5/刘东升/7-4 二分查找.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include<bits/stdc++.h>
using namespace std;
int a[1001];
int cnt=0;
int se(int l,int r,int key)
{
int mid=(l+r)/2;
if(l>r)
{
return -1;
}
if(key==a[mid])
{
cnt++;
return mid;
}
else if(key>a[mid])
{
l=mid+1;
cnt++;
se(l,r,key);
}
else
{
r=mid-1;
cnt++;
se(l,r,key);
}
}

int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int key;
cin>>key;
cout<<se(0,n-1,key)<<endl;
cout<<cnt;

return 0;
}
73 changes: 73 additions & 0 deletions winter-day5/刘东升/7-5 冰岛人.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include<bits/stdc++.h>
using namespace std;

struct people
{
char sex;
string father;
};

map<string,people> mp;

int judge(string a,string b)
{
int i,j;
i=1;
for(string A=a;!A.empty();A = mp[A].father,i++)
{
j=1;//��ʼ�ֱ�Ƚ�
for(string B = b;!B.empty();B = mp[B].father,j++)
{
if(i>=5&&j>=5) return 1;//�Ѿ������������������
if(A==B&&(i<5||j<5)) return 0;//������ҵ���ͬ���ȡ�
}
}
return 1; //�޹�ͬ����,����Ҫ��
}

int main()
{
int n;
cin>>n;
string a,b;
for(int i=0;i<n;i++)
{
cin>>a>>b;
if(b.back() == 'r')//ά��Ů
{
mp[a] = {'f',b.substr(0,b.size()-7)};//����������Ů�����գ�ȥ��"sdottir"

}
else if(b.back() == 'n')//����
{
mp[a] = {'m',b.substr(0,b.size()-4)};//ȥ��"sson"
}
else
{
mp[a].sex = b.back();
}
}

int m;
cin>>m;
string s;
for(int i=0;i<m;i++)
{
cin>>a>>s>>b>>s;
if(mp.find(a) == mp.end()||mp.find(b) == mp.end())//���Ƿ����˲���������
cout<<"NA"<<endl;
else if(mp[a].sex == mp[b].sex) //���Ƿ�ͬ��
cout<<"Whatever"<<endl;
else
{
if(judge(a,b))
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
}
}
}
Loading