| 题目 | 难度 | 知识点 |
|---|---|---|
| A 和猫猫一起起舞! | ★ | 签到 |
| B 冒险猫猫参上!! | ★ | 签到 |
| C 泉神,启动!!! | ★ | 构造 |
| D 大预言家!!!! | ★ | 思维/找规律 |
| E 全都要!!!!! | ★ | DP |
| F 水题!!!!!! | ★★ | 分层图 |
和猫猫一起起舞!
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
char c; cin>>c;
if(c=='U' || c=='D') puts("L");
else puts("U");
return 0;
}
冒险猫猫参上!!
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int t; cin>>t;
while(t--)
{
int n; cin>>n;
for(int i=0;i<n;i++)
{
if(i&1) cout<<"1 ";
else cout<<"2 ";
}
puts("");
}
return 0;
}
泉神,启动!!!
例如: 23构造成2323即可
同理 1234 构造成12341234即可。
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int t; cin>>t;
while(t--)
{
int x; cin>>x;
string s; s=to_string(x);
cout<<1;
for(int i=1;i<=s.size()-1;i++) cout<<"0";
cout<<1<<'\n';
}
return 0;
}
大预言家!!!!
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
int main(void)
{
LL t; cin>>t;
while(t--)
{
LL n; cin>>n;
LL len=sqrt(n);
LL temp=n-len*len;
if(len&1)
{
LL x=len/2,y=len/2;
if(temp>1) x++,temp--;
if(temp<=len) y-=temp,temp=0;
else{
y-=len,temp-=len;
x-=temp;
}
cout<<x<<" "<<y<<'\n';
}else
{
LL x=-(len/2-1),y=-(len/2);
if(temp>=1) x--,temp--;
if(temp<=len) y+=temp,temp=0;
else
{
y+=len,temp-=len;
x+=temp;
}
cout<<x<<" "<<y<<'\n';
}
}
return 0;
}
全都要!!!!!
#include<bits/stdc++.h>
using namespace std;
const int N=1e4+10;
const int M=1e3*3+10;
typedef long long int LL;
LL f[N][M],a[N],n,k;
int main(void)
{
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=0;i<=n;i++)
for(int j=0;j<=k;j++) f[i][j]=-1e18;
f[0][0]=0;
for(int i=1;i<=k;i++)
{
for(int j=1;j<=n;j++)
{
for(int z=1;z<=6;z++)
{
int l=j-z,r=j;
if(l>=0&&f[l][i-1]!=-1e18)
f[r][i]=max(f[r][i],f[l][i-1]+a[j]);
}
}
}
LL ans=-1e18;
for(int i=1;i<=n;i++) ans=max(ans,f[i][k]);
cout<<ans;
return 0;
}
水题!!!!!!
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int N=1010;
bool vis[2][N][N];
struct node
{
int x,y,t,drop;
bool operator<(const node a)const{
return t>a.t;
}
};
void solve()
{
int n,m,h; cin>>n>>m>>h;
string s[N];
for(int i=0;i<n;i++) cin>>s[i];
memset(vis,0,sizeof vis);
int sx,sy,ex,ey;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(s[i][j]=='*') sx=i,sy=j;
else if(s[i][j]=='%') ex=i,ey=j;
}
}
priority_queue<node>q; q.push({sx,sy,0,1});
while(q.size())
{
node temp=q.top(); q.pop();
int x=temp.x,y=temp.y,t=temp.t,drop=temp.drop;
if(vis[drop][x][y]) continue;
vis[drop][x][y]=1;
if(x==ex&&y==ey)
{
cout<<t<<'\n';
return;
}
if(drop)//有破坏能力
{
if(x+1<n)
{
if(s[x+1][y]=='#'){
q.push({x+1,y,t+h+1,1});//破坏障碍物直接下
q.push({x,y,t,0});//水流左右两边要跑。
}else{
q.push({x+1,y,t+1,1});//直接下
}
}
}
else//无破坏能力
{
if(x+1<n)
{
if(s[x+1][y]=='#')//左右跑
{
if(y-1>=0&&s[x][y-1]!='#'){//左边移动
q.push({x,y-1,t+1,0});
}
if(y+1<n&&s[x][y+1]!='#'){//右边移动
q.push({x,y+1,t+1,0});
}
}
else//直接下
{
q.push({x,y,t,1});
}
}
}
}
cout<<-1<<'\n';
}
int main(void)
{
int t; t=1;
while(t--) solve();
return 0;
}