跳到正文

个人记录

蒟蒻的来做梦8.14总结

__IE14约 4 分钟
原文
文章信息与版本

文章信息

发布
2025年8月14日
收录
2025年12月12日
更新
2026年11月11日
篇幅
约 4 分钟
获赞
1

版本

  1. v1当前

应该没人写了笔记吧但还是放一个黑板

T637642 比较数字

C++
#include<iostream>

using namespace std;
string s;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	cin>>s;
	for(int i=s.find("0");i<s.size();i++){
		s[i]='1';
	}
	cout<<s;
	return 0;
}

T637627 张的弓

C++
#include<iostream>

using namespace std;
long long t;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	cin>>t;
	while(t--){
		long long n,m,k;
		cin>>n>>m>>k;
		long long ans=k/(2*n+2)*2;
		{
			long long x=1,y=1,flag=0;
			for(long long i=1;i<=k%(2*n+2);i++){
				if(flag){
					if(x==1){
						y++;
						flag=0;
					}else{
						x--;
					}
				}else{
					if(x==n){
						y++;flag=1;
					}else{
						x++;
					}
				}
			}
			ans+=x+y-2;
		}
		cout<<ans<<'\n';
	}
	return 0;
}

T637602 可可口乐

C++
#include<iostream>
#include<queue>
#include<set>
using namespace std;
string s;
class bfs_class{
	queue<pair<string,int> >q;
	set<string>st;
public:
	void run(){
		q.push(make_pair(s,0));
		st.insert(s);
		while(q.size()){
			auto tp=q.front();
			q.pop();
			auto &tpf=tp.first;
			if(tpf=="cocacola"){
				cout<<tp.second;
				return;
			}
			for(size_t i=0;i<tpf.size();i++){
				for(size_t t=0;t<tpf.size();t++){
					if(i!=t){
						swap(tpf[i],tpf[t]);
						if(st.find(tpf)==st.end()){
							q.push(make_pair(tpf,tp.second+1));
							st.insert(tpf);
						}
						swap(tpf[i],tpf[t]);
					}
				}
			}
		}
	}
}bfs;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	cin>>s;
	bfs.run();
	return 0;
}

T637561 小梦的守卫

C++

本页面的全部内容在CC BY-NC-ND 4.0 和 SATA 协议之条款下提供,附加条款亦可能应用

原文