2022/4/15 天梯赛刷题记录&2021天梯赛

L1-1~L1-8 语法题
L2-1 模拟、stl
L2-2
L2-3 stl
L2-4 模拟

L1-1 人与神

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl '\n';
typedef long long ll;
typedef pair<string,int> PII;
const int N=1e6+10,mod=1e9+7;
int main(){
	IOS;
	cout<<"To iterate is human, to recurse divine."<<endl;
	return 0;
}

L1-2 两小时学完C语言

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl '\n';
typedef long long ll;
typedef pair<string,int> PII;
const int N=1e6+10,mod=1e9+7;
int n,k,m;
int main(){
	IOS;
	cin>>n>>k>>m;
	cout<<n-k*m<<endl;
	return 0;
}

L1-3 强迫症

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl '\n';
typedef long long ll;
typedef pair<string,int> PII;
const int N=1e6+10,mod=1e9+7;
string s;
int main(){
	IOS;
	cin>>s;
	int n=s.size();
	if(n==6){
		cout<<s[0]<<s[1]<<s[2]<<s[3]<<"-"<<s[4]<<s[5];
		return 0;
	}
	int tt=(s[0]-'0')*10+(s[1]-'0');
	if(tt<22){
		cout<<"20"<<s[0]<<s[1]<<"-"<<s[2]<<s[3];
		return 0;
	}
	cout<<"19"<<s[0]<<s[1]<<"-"<<s[2]<<s[3];
	return 0;
}

L1-4 降价提醒机器人

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl '\n';
typedef long long ll;
typedef pair<string,int> PII;
const int N=1e6+10,mod=1e9+7;
int n,m;
double a[N];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i];
	vector<double>ans;
	for(int i=1;i<=n;i++){
		if(a[i]<m) ans.push_back(a[i]);
	}
	for(auto i:ans){
		printf("On Sale! %.1lf\n",i);
	}
	return 0;
}

L1-5 大笨钟的心情

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl '\n';
typedef long long ll;
typedef pair<string,int> PII;
const int N=1e6+10,mod=1e9+7;
int a[N];
int main(){
	for(int i=0;i<=23;i++) cin>>a[i];
	while(1){
		int x;cin>>x;
		if(x<0||x>23) break;
		if(a[x]>50) {
			cout<<a[x]<<" "<<"Yes"<<endl;
		}else{
			cout<<a[x]<<" "<<"No"<<endl;
		}
	} 
	return 0;
}

L1-6 吉老师的回归

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl '\n';
typedef long long ll;
typedef pair<string,int> PII;
const int N=1e6+10,mod=1e9+7;
int n,m;
int main(){
	cin>>n>>m;
	int f=1;
	string s;
	getchar();
	while(n--){
		getline(cin,s);
		if(s.find("qiandao")!=-1||s.find("easy")!=-1)continue;
		if(m==0){
			cout<<s;
			f=0;
			break;
		}
		m--;
	}
	if(f)cout<<"Wo AK le"<<endl;
	return 0;
}

L1-7 天梯赛的善良

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl '\n';
typedef long long ll;
typedef pair<string,int> PII;
const int N=1e6+10,mod=1e9+7;
int n,a[N];
int main(){
	cin>>n;
	for(int i=1;i<=n;++i) cin>>a[i];
	int maxn=0,minx=1e7,pos1=0,pos2=0;
	for(int i=1;i<=n;i++){
		if(a[i]>maxn) maxn=a[i];
		if(a[i]<minx) minx=a[i];
	}
	for(int i=1;i<=n;i++){
		if(a[i]==maxn) pos1++;
		if(a[i]==minx) pos2++;
	}
	cout<<minx<<" "<<pos2<<endl;
	cout<<maxn<<" "<<pos1<<endl;
	return 0;
}

L1-8 乘法口诀数列

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl '\n';
typedef long long ll;
typedef pair<string,int> PII;
const int N=1e6+10,mod=1e9+7;
int n,a[N];
int main(){
	cin>>a[1]>>a[2]>>n;
	for(int i=3,j=3;i<=n;j++){
		int x=a[j-1]*a[j-2];
		if(x<10){
			a[i++]=x;
		}else {
			a[i++]=x/10;
			a[i++]=x%10;
		}
	}
	for(int i=1;i<n;i++) cout<<a[i]<<" ";
	cout<<a[n]<<endl;
	return 0;
}

L2-1 包装机

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int N=1e3+10,mod=1e9+7;
int n,m,s;
queue<char> q[110];
stack<char> st;
int main(){
    cin>>n>>m>>s;
    for(int i=1;i<=n;i++) {
        string str;
        cin>>str;
        for(int j=0;j<str.size();j++) q[i].push(str[j]);
    } 
    int a;
    while(cin>>a&&a!=-1) {
        if(a==0) {
            if(st.size())   {
                cout<<st.top();
                st.pop();
            }
        }
        else {
             if(st.size()==s)  {
                if(q[a].size())  {
                    cout<<st.top();
                    st.pop();
                    st.push(q[a].front());
                    q[a].pop();
                }
            }
            else {
                if(q[a].size()){
                    st.push(q[a].front());
                    q[a].pop();
                }
            }
        }
    }
    return 0;
}

L2-3 清点代码库

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl '\n';
typedef long long ll;
typedef pair<vector<int>,int> PII;
const int N=1e5+10,mod=1e9+7;
map<vector<int>,int>mp;
vector<int>e[N];
struct cmp{
	bool operator() (const PII &a,const PII &b) const {
		if(a.second==b.second) return a.first<b.first;
		return a.second>b.second;
	}
};
set<PII,cmp>st;
int n,m;
int main(){
	IOS;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int x;cin>>x;
			e[i].push_back(x);
		}
	}
	for(int i=1;i<=n;i++) mp[e[i]]++;
	for(auto i:mp) st.insert({i.first,i.second});
	cout<<st.size()<<endl;
	for(auto i:st){
		cout<<i.second<<" ";
		int cnt=0;
		for(auto j:i.first) {
			cnt++;
			if(cnt!=m) cout<<j<<" ";
			else cout<<j;
		}
		cout<<endl;
	}
	return 0;
}

L2-4 哲哲打游戏

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl '\n';
typedef long long ll;
typedef pair<ll,ll> PII;
const int N=1e5+10,mod=1e9+7;
int n,m;
vector<int>e[N];
int a[N];
int main(){
	IOS;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		int k;cin>>k;
		for(int j=1;j<=k;j++){
			int x;cin>>x;
			e[i].push_back(x);
		}
	}
	int ans=1;
	for(int i=1;i<=m;i++) {
		int op,y;cin>>op>>y;
		if(op==0) ans=e[ans][y-1];
		else if(op==1){
			a[y]=ans;
			cout<<ans<<endl;
		}else{
			ans=a[y];
		}
	}
	cout<<ans<<endl;
	return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

学不会数据库

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值