比赛地址:牛客竞赛_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ (nowcoder.com)
A.小红的好数
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
void solve() {
ll n;
cin>>n;
if(n>=10&&n<=99)
{
if(n%10==n/10)
{
cout<<"Yes";
return;
}
}
cout<<"No";
}
signed main() {
ios::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
ll t = 1;
// std::cin >> t;
while (t--) {
solve();
}
}
B.小红的好数组
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
void solve() {
ll n,m;
cin>>n>>m;
int num[n+10];
for(int i=1;i<=n;i++)
{
cin>>num[i];
}
int i,j;
int good_num=0;
int error1;
if(m%2)
{
i=(m/2)+1;
j=m/2;
for(;i<=n-j;i++)
{
error1=0;
for(int a1=1;a1<=j;a1++)
{
if(num[i-a1]!=num[i+a1])
{
error1++;
}
}
if(error1==1)
{
good_num++;
}
}
}
else
{
i=m/2;
j=m/2;
for(;i<=n-j;i++)
{
error1=0;
for(int a1=1;a1<=j;a1++)
{
if(num[i-a1+1]!=num[i+a1])
{
error1++;
}
}
if(error1==1)
{
good_num++;
}
}
}
cout<<good_num;
}
signed main() {
ios::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
ll t = 1;
// std::cin >> t;
while (t--) {
solve();
}
}
C.小红的矩阵行走
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
int ssr[1001][1001];
ll n,m;
int key;
void dfs(int i,int j,int num)
{
if(i>n||i<=0||j>m||j<=0)
{
return;
}
if(i==n&&j==m&&key==1)
{
key=0;
cout<<"Yes"<<endl;
}
if(ssr[i+1][j]==num)
{
dfs(i+1,j,num);
}
if(ssr[i][j+1]==num)
{
dfs(i,j+1,num);
}
}
void solve() {
cin>>n>>m;
key=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>ssr[i][j];
}
}
dfs(1,1,ssr[n][m]);
if(key)
{
cout<<"No"<<endl;
}
}
signed main() {
ios::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
ll t = 1;
cin >> t;
while (t--) {
solve();
}
}
D.小红的行列式构造
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
void solve(ll x) {
ll a,b,c;
if (x > 0) {
a = x + 5;
b = 1;
c = 2;
cout << a << " -1 -1\n"
<< "-1 " << b << " -1\n"
<< "-1 -1 " << c;
} else if (x < 0) {
a = x-5;
b = -1;
c = -2;
cout << a << " 1 1\n"
<< "1 " << b << " 1\n"
<< "1 1 " << c;
} else {
cout <<"1 1 1\n"
<<"1 1 1\n"
<<"1 1 1\n";
}
}
signed main() {
ios::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
ll x;
cin >> x;
solve(x);
return 0;
}
标签:int,题解,ll,namespace,long,牛客,63,solve,define From: https://blog.csdn.net/song0789/article/details/142929690