ccpc网络选拔赛总结

Primality Test
一开始再看f题,吧f题读完后,发现d题都过了好几百了。于是连忙赶过来看d。
题意很简单。结论也很容易想。
就是除了2和 3 相加除以2取整的值不是质数之外。其余两个相邻质数相加除以2得到的都不是质数。
因为两个质数相加除以2得到的值。就是这两个相邻质数中间的一个数,两个相邻质数中间的数肯定不是质数。而且因为除了2,其余质数都是奇数,所以除以2肯定是直接取整的。
所以结论就是除了1是yes,其他都是no

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define endl '\n'
const int inf=0x3f3f3f3f;
const int MAXN=1e5+10;
int n,m,T;
int flag; 


int main() 
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>T;
	while(T--){
		ll a;
		cin>>a;
		if(a==1){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

Kanade Doesn’t Want to Learn CG
ysj读完题,说是一个几何题目,就是给你一条,篮球的抛物线,问你能不能进球。为了方便考虑,吧那些都当做质点,然后因为考虑边界的问题。犹豫了好久,好像别的队也有些在犹豫边界。
因为有篮板,篮球可以考虑碰到篮板后反弹然后进框。所以其实可以将蓝框直接延长一个蓝框的长度即可。只是还要如果是在延长的那一部分进球的话就需要判断有没有碰到篮板。

#include<iostream>
#include<algorithm>
using namespace std;
double a, b, c, x0, x1, z0, z1, z2;
double fun(double x)
{
	return a * x * x + b * x + c;
}
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> a >> b >> c;
		cin >> x0 >> x1 >> z0 >> z1 >> z2;
		double yy0 = fun(x0);
		double yy1 = fun(x1);
		double dyy0 = fun(x0 + 2 * (x1 - x0));
		if (yy0 > z0 && yy1 <= z2 && yy1 > z0)
		{
			if (dyy0 < z0)
			{
				cout << "Yes" << endl;
			}
			else
			{
				cout << "No" << endl;
			}
		}
		else if (yy0 > z0 && yy1 < z0)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
}

Nun Heh Heh Aaaaaaaaaaa
就是先处理了前缀。因为前缀是固定的,所以就是相当于前缀确定了之后,和后面的a进行排列组合。
除了0个a的情况。所以n个a有 2^n-1种情况。
后面的a的个数很容易求。一个O(n)就能解决。
所以主要是处理前缀。
处理前缀就是,遇到了前缀里面的一个字母,那么他就可以贡献他这个字母的前一个字母能贡献的这这么多,然后累加即可。然后没取模wa了好几发
ps.记得快速乘和快速幂

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define endl '\n'
const int inf=0x3f3f3f3f;
const int MAXN=1e5+10;
const ll mod=998244353;
int n,m,T;
int flag; 

ll num[10];
ll ksm(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1) ans=(ans*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

ll ksmc(ll a,ll b){
	ll ans=0;
	while(b){
		if(b&1) ans=(ans+a)%mod;
		a=(2*a)%mod;
		b>>=1;
	}
	return ans;
}
ll a[MAXN];
int main() 
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>T;
	while(T--){
		string s;
		cin>>s;
		int len=s.size();
		memset(a,0,sizeof(a));
		for(int i=len-1;i>=0;i--){
			if(s[i]=='a'){
				a[i]=a[i+1]+1;
			}else{
				a[i]=a[i+1];
			}
		}
		memset(num,0,sizeof(num));
		for(int i=0;i<len;i++){
			if(s[i]=='n'){
				num[3]+=num[2]%mod;
				num[1]++;
			}else if(s[i]=='u'){
				num[2]+=num[1]%mod;
			}else if(s[i]=='h'){
				num[9]=(num[9]+ksmc(num[8],(ksm(2,a[i+1])-1))%mod)%mod;
				num[7]+=num[6]%mod;
				num[6]+=num[5]%mod;
				num[4]+=num[3]%mod;

			}else if (s[i]=='e'){
				num[8]+=num[7]%mod;
				num[5]+=num[4]%mod;
			}
		}
		cout<<(num[9]%mod)<<endl;
	}
	return 0;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值