【解题报告】CF EDU #ROUND 107A~D

【解题报告】CF EDU #ROUND 107A~D

比赛链接
打烂了,又要掉分了呜呜呜,教育场日常被教育。
疯狂读错题目啊啊啊

A. Review Site

思路
脑子抽了WA了一发,这题直接type1放第一个,type2放第二个,type3放第一个就可以了
代码

// Problem: A. Review Site
// Contest: Codeforces - Educational Codeforces Round 107 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1511/problem/A
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// FishingRod
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long LL;
typedef pair<int,int> PII;

/*DATA & KEY

*/
int T;
const int N=55;
int r[N];
void solve(int T)
{
	//NEW DATA CLEAN
	memset(r,0,sizeof r);
	//NOTE!!!
	int n;cin>>n;
	for(int i=1;i<=n;i++)cin>>r[i];
	int ans=0;
	for(int i=1;i<=n;i++)
		if(r[i]==1||r[i]==3)ans++;
	cout<<ans<<endl;	
}

int main()
{
	scanf("%d",&T);
	while(T--)solve(T);
	return 0;
}

B

思路
没看清题目疯狂WA,以后还是自己阅读理解翻译,不然老是跳着读题直接白给
digits:位,一般就是长度的意思。
题意大概就是构造长度为a和b的数字,让他们的gcd 长度 为c

先构造一波,我们直接c用1,10,100这种,然后长度a,b弄成互质的,为了防止特殊情况直接暴力微调即可
代码

// Problem: B. GCD Length
// Contest: Codeforces - Educational Codeforces Round 107 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1511/problem/B
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// FishingRod
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long LL;
typedef pair<int,int> PII;

/*DATA & KEY

*/
int T;

void solve(int T)
{
	//NEW DATA CLEAN
	
	//NOTE!!!
	int a,b,c;cin>>a>>b>>c;
	int n=1,m=1,t=1;
	for(int i=1;i<c;i++)t*=10;
	for(int i=1;i<=a-c;i++)n*=10;
	if(n!=1)n+=1;
	for(int i=1;i<=b-c;i++)m*=10;
	if(m!=1)m+=3;
	while(__gcd(n,m)!=1)n++;
	LL x=n*t,y=m*t;

	cout<<x<<" "<<y<<endl;
	
}

int main()
{
	scanf("%d",&T);
	while(T--)solve(T);
	return 0;
}

C. Yet Another Card Deck

前两题直接心态写炸了,后面也就干不动了。应该是一道模拟题,但是由于忘记这题没有多组输入,忘记把输入的solve改掉了,导致半天没调出来
思路

代码

// Problem: C. Yet Another Card Deck
// Contest: Codeforces - Educational Codeforces Round 107 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1511/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// FishingRod
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long LL;
typedef pair<int,int> PII;

/*DATA & KEY

*/
int T;
const int N=3e5+10;
int c[N];
void solve()
{
	//NEW DATA CLEAN
	memset(c,0,sizeof c);
	vector<int>v;
	//NOTE!!!
	int n,q;cin>>n>>q;
	for(int i=1;i<=n;i++)cin>>c[i];
	for(int i=n;i>=1;i--)v.push_back(c[i]);
	while(q--)
	{
		int x;cin>>x;
		int len=v.size();
		for(int i=len-1;i>=0;i--)
		{
			if(v[i]==x)
			{
				cout<<n-i<<" ";
				v.erase(v.begin()+i);
				break;
			}
		}
		v.push_back(x);
	}

}

int main()
{
//	scanf("%d",&T);
//	while(T--)solve(T);
	solve();
	return 0;
}

D. Min Cost String

在这里插入图片描述

思路
构造题
把样例模拟一遍,发现规律

aa
ab
ba
ac
ca
ad
db
bb

a ab ac ad bb

把上面规律打出来然后一直循环直到长度足够为止。输出截取的答案子串
代码

// Problem: D. Min Cost String
// Contest: Codeforces - Educational Codeforces Round 107 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1511/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// FishingRod

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long LL;
typedef pair<int,int> PII;
//#define MULINPUT
/*DATA & KEY
n 1 2e5
k 1 26
*/
int T;
void solve()
{
	//NEW DATA CLEAN
	
	//NOTE!!!
	int n,k;cin>>n>>k;
	string s;
	for(int i=0;i<k;i++)
		for(int j=i;j<k;j++)
		{
			if(j!=i)s+='a'+i;
			s+='a'+j;
		}
	while(s.size()<n)s+=s;
	cout<<s.substr(0,n)<<endl;
}

int main()
{
	#ifdef MULINPUT
		scanf("%d",&T);
		for(int i=1;i<=T;i++)solve();
	#else
		solve();
	#endif
	return 0;
}

反思

A:

当某个分支对答案贡献受正贡献和负贡献影响,尽量让他受正贡献影响。

B:

认真读题,注意digit表示是长度位数

C:

vector容器的正序逆序遍历,插入特点时从尾巴插,掌握删除操作
注意看题目到底有没有多组输入!(以修改做题板子)

D:

构造题目,模拟样例很重要!
英文翻译里

such that A and B 表示同时满足A和B

对于答案:ans=特例+模块+模块+模块,可以采用

while(ans.size())ans+=mode;
cout<<ans.substr(0,n);

这样可以免去计算要多少个模块达到长度

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值