38

9小时前

#include<iostream>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define N 1010
int w[N] = {0};

int main()
{
IOS;
int n, m;
cin >> n >> m;
for (int i = 0;i < n;i++)
{
cin >> w[0];
if (w[0] < 1000) w[w[0]]++;
}
for (int i = 1;i < m / 2;i++)
{
w[i]--;
w[m - i]--;
if (w[i] >=0 && w[m - i] >= 0)
{
cout << i << " " << m - i << endl;
return 0;
}
}
cout << "No Solution" << endl;
return 0;
}

1天前

#include<iostream>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define N 100010

int n, m;
int w[N];

bool check(double mid)
{
int cnt = 0;
for (int i = 0;i < n;i++)
cnt += w[i] / mid;
return cnt >= m;
}

int main()
{
IOS;
cin >> n >> m;
for (int i = 0;i < n;i++) cin >> w[i];

double l = 0, r = 1e9;
for (int i = 0;i < 100;i++)
{
double mid = (l + r) / 2;
if (check(mid)) l = mid;
else r = mid;
}
printf("%.2lf\n", r);
return 0;
}

1天前

#include<iostream>
#include<string>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
IOS;
string s1, s2;
cin >> s1 >> s2;
int num = s1.length(), sum = 0;
for (int i = 0;i < num - 1;i++)
{
if (s1[i] != s2[i])
{
s1[i] = s2[i];
if (s1[i + 1] == '*') s1[i + 1] = 'o';
else s1[i + 1] = '*';
sum++;
}
}
cout << sum;
return 0;
}

2天前

#include<iostream>
#include<algorithm>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;

struct Student
{
int Score;
int Chinese;
int Num;
}Stu[305];

int cmp(Student s1, Student s2)
{
if (s1.Score != s2.Score)
return s1.Score > s2.Score;
else if (s1.Chinese != s2.Chinese)
return s1.Chinese > s2.Chinese;
else
return s1.Num < s2.Num;
}

int main()
{
IOS;
int n;
cin >> n;
int C, M, E;
for (int i = 1;i <= n;i++)
{
cin >> C >> M >> E;
Stu[i].Score = C + M + E;
Stu[i].Chinese = C;
Stu[i].Num = i;
}
sort(Stu + 1, Stu + 1 + n, cmp);
for (int i = 1;i <= 5;i++)
cout << Stu[i].Num << " " << Stu[i].Score << endl;
return 0;
}

3天前

#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
int s[10005] = {};

int main()
{
IOS;
int l, m;
int begin ,end;
cin >> l >> m;
int size = sizeof(s[0]);
for (int i = 0;i < m;i++)
{
cin >> begin >> end;
memset(&s[begin], -1, (end - begin +1) * size);
}
int sum = 0;
for (int i = 0;i <= l; i++)
{
if (s[i] == 0)sum++;
}
cout << sum;
return 0;
}

6天前

#include <bits/stdc++.h>
using namespace std;

//该函数参考了博客https://www.cnblogs.com/zwjjj/p/9953718.html
{
string ans="";
do{
if(t>=0&&t<=9)    ans+=t+'0';
else ans+=t-10+'A';
}while(n!=0);    //使用do{}while（）以防止输入为0的情况
reverse(ans.begin(),ans.end());
return ans;
}

int main()
{
int b;
string s;
cin >> b;
for ( int i=1;i<=300;i++ )
{
s=intToA(i*i,b);
int n=s.length();
int j;
for( j=0;j<n/2 && s[j]==s[n-j-1];j++ );
if( j==n/2 )
{
cout << intToA(i,b) << " " << s <<endl;
}
}
return 0;
}

6天前

#include <bits/stdc++.h>
using namespace std;

//该函数参考了博客https://www.cnblogs.com/zwjjj/p/9953718.html
{
string ans="";
do{
if(t>=0&&t<=9)    ans+=t+'0';
else ans+=t-10+'A';
}while(n!=0);    //使用do{}while（）以防止输入为0的情况
reverse(ans.begin(),ans.end());
return ans;
}

int main()
{
int b;
string s;
cin >> b;
for ( int i=1;i<=300;i++ )
{
s=intToA(i*i,b);
int n=s.length();
int j;
for( j=0;j<n/2 && s[j]==s[n-j-1];j++ );
if( j==n/2 )
{
cout << intToA(i,b) << " " << s <<endl;
}
}
return 0;
}

7天前

#include<bits/stdc++.h>
using namespace std;

const int N = 25;

int n, m;
char g[N][N];//存储地板
bool st[N][N];//存储状态，该位置地板是否被走过

int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};//上右下左四个方向

int dfs(int x, int y)//深度优先遍历
{
int cnt = 1;

st[x][y] = true;
for (int i = 0; i < 4; i ++ )//走四个方向
{
int a = x + dx[i], b = y + dy[i];
if (a < 0 || a >= n || b < 0 || b >= m) continue;
if (g[a][b] != '.') continue;
if (st[a][b]) continue;

cnt += dfs(a, b);//如果可以走向某一个方向，对该方向上的点递归
}

return cnt;
}

int main()
{
while (cin >> m >> n, n || m)
{
for (int i = 0; i < n; i ++ ) cin >> g[i];//一次读入一行

int x, y;
for (int i = 0; i < n; i ++ )
for (int j = 0; j < m; j ++ )
if (g[i][j] == '@')
{
x = i;
y = j;
}

memset(st, 0, sizeof st);//清空状态数组
cout << dfs(x, y) << endl;
}

return 0;
}
//参考了猿六