牛客寒假训练营3
M 牛客传送门
代码如下:
const int N=2e6+10,M=1e4+10;
const int INF=0x3f3f3f3f;
const int mod=998244353;
ll n;
void solve(){
string s; cin >> s;
string ns="nowcoder";
sort(s.begin(),s.end());
sort(ns.begin(),ns.end());
if(ns==s) cout << "happy new year";
else cout << "I AK IOI";
}
A 牛客传送门
大胆猜结论
代码如下:
const int N=2e6+10,M=1e4+10;
const int INF=0x3f3f3f3f;
const int mod=998244353;
ll n;
void solve(){
cin >> n;
if(n&1) cout << "Yes";
else cout << "No";
}
F 牛客传送门
代码如下:
const int N=2e6+10,M=1e4+10;
const int INF=0x3f3f3f3f;
const int mod=998244353;
ll n;
void solve(){
cin >> n;
ll tot=0;
for(int i=1;i<=3;i++){
int a; cin >> a;
tot+=a;
}
if(tot>=n && tot<=n*2) cout << "Yes\n";
else cout << "No\n";
}
L 牛客传送门
思路:先找规律再模拟实现
代码如下:
const int N=2e6+10,M=1e4+10;
const int INF=0x3f3f3f3f;
const int mod=998244353;
ll n;
int a[22][22];
void dfs(int tx,int ty){
int x=tx,y=ty;
cout << a[x][y] << " ";
if(tx==n && ty==n*2-1){
while(x>1) x--,y--,cout << a[x][y] << " ";
return ;
}
x++,y--;
cout << a[x][y] << " ";
while(x<n){
x++,y++;
cout << a[x][y] << " ";
y-=2;
cout << a[x][y] << " ";
}
while(x>tx+1){
x--,y++;
cout << a[x][y] << " ";
}
dfs(x,y+2);
}
void solve(){
cin >> n;n++;
ll num=1;
for(int i=1;i<=n;i++)
for(int j=n-i+1;j<=n-i+1+(i-1)*2;j+=2) a[i][j]=num++;
cout << "Yes\n";
dfs(1,n);
}
未完待续