Codeforces Round #617 (Div. 3)

A

题意:给一个长度为n的数组,可以进行任意次操作:对于所有的i,j满足i≠j使得ai=aj,使得最后的数组元素和为奇数。
思路:很简单,如果n为奇数看看数组里有没有奇数,有就可以,如果n为偶数看看数组里是否同时含有奇数和偶数,有就可以
代码

/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
int Xiaobo()
{
	int t;
	cin>>t;
	while(t--) {
		int n;
		cin>>n;
		int j=0,o=0;
		for(int i=1;i<=n;i++) {
			int x;
			scanf("%d",&x);
			if(x%2) j=1;
			else o=1;
		}
		if(n%2&&j) cout<<"YES\n";
		else if(n%2==0&&j&&o) cout<<"YES\n";
		else cout<<"NO\n";
	} 
	return 0;
}

B. Food Buying

题意:某某有s元,可以买x元的东西,返回x/10向下取整的金额,问最多可以买多少元的商品
思路:乱搞暴力吧,指定有公式吧,本来我想的是(s+s/10)/10+s结果发现不太行,哈哈然后就看了好多人过了就爆吧,,,

/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
int Xiaobo()
{
	int t;
	cin>>t;
	while(t--) {
		int s;
		scanf("%d",&s);
		ll sum=0;
		while(s>=10) {
			int k=s/10;
			sum+=k*10;
			s%=10;
			s+=k;
		}
		cout<<sum+s<<'\n';
	}
	return 0;
}

C

题意:给一个字符串包含"ULRD",U代表向上移动一格,L代表向左移动一格,R代表向右移动一格,D代表向下移动一格,问是否可以删除一些连续序列使得对最后的位置没有影响。还有个坑的地方,刚开始没看到 要要求这个序列尽可能的小 比如有个RULDRL显然把第5,6个字符删除了最小
思路:用map记录下每个位置,如果当前位置在之前出现过(此时肯定可以删除一段序列因为之前已经到达过这个位置,那么之间的序列就是无用的)就去记录答案顺便更新下最小值,,,
代码:

/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
typedef pair<int,int>PII;
map<PII,int>mp;
int Xiaobo()
{
	int t;
	cin>>t;
	while(t--) {
		string s;
		if(!mp.empty()) mp.clear();
		int n;
		cin>>n;
		cin>>s;
		int x=0,y=0;
		int flag=0;
		int ansx=0,ansy=mod;
		for(int i=0;i<s.size();i++) {
			mp[{x,y}]=i+1;
			if(s[i]=='L') x--;
			if(s[i]=='R') x++;
			if(s[i]=='U') y++;
			if(s[i]=='D') y--;
			PII p={x,y};
			if(mp[p]) {
				flag=1;
				//cout<<mp[p]<<' '<<i+1<<'\n';
				//break;
				if(i+1-mp[p]<ansy-ansx) {
					ansx=mp[p];
					ansy=i+1;
				}
				mp[p]=i+1;
			}
			else mp[p]=i+1;
		}
		if(!flag) cout<<-1<<'\n';
		else cout<<ansx<<' '<<ansy<<'\n';
	}
	return 0;
}

D

题意:有n个怪物排成一排,每个怪物都有一定的血量值HP。你和你的对手一起去打怪升级,你的攻击力是a,对手的攻击力是b,每次都是轮流攻击,假如你的最后一次攻击打败了怪兽那么你就得1分,反之不得分,你有k次魔法操作,可以使得对手跳过本回合,这样你就可以攻击怪物了,当怪物血量小于0时即被打败。问:最多可以得多少分?
思路:
贪心吧,先预处理出每个怪物如果被自己打败需要多少次魔法操作,然后排下序,扫一遍数组记录答案就行了。预处理的时候是算yu=num[i]%(a+b),如果余数等于0就算最后一次操作,及怪物的剩余血量值为yu=b否则就让yu-=a,其实就是模拟最后一次你攻击以后怪物剩余的血量值,然后看这样的血量值下需要的最小的魔法操作,及如果**(yu%a)?(yu/a+1):(yu/a)**,,,挺好想的,
代码:

/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
int num[maxn];
int xy[maxn];
int Xiaobo()
{
	int n,a,b,k;
	cin>>n>>a>>b>>k;
	ll zg=a+b;
	for(int i=1;i<=n;i++) {
		cin>>num[i];
		int yu=num[i]%(a+b);
		if(yu==0) yu=b;
		else yu-=a;
		if(yu<=0) {
			xy[i]=0;
			continue;
		} 
		int ans=(yu%a)?(yu/a+1):(yu/a);
		xy[i]=ans;
	}
	sort(xy+1,xy+1+n);
	int sum=0;
	for(int i=1;i<=n;i++) {
		if(k>=xy[i]) sum++,k-=xy[i];
		else break;
	}
	cout<<sum<<'\n';
	return 0;
}

E、F还是太弱了,就剩30分钟了没调出来,明天再补吧,本来今天的牛客很自闭,导致心情不是很好还记错时间了开局15分钟才过来,总结下这场cf还好吧,有所收获,有所不足,继续补题加油吧!!!Never give up!Never give up!Never give up!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值