2021CCPC网络赛重赛菜鸡签到

重赛的签到三连

没想到啊,煎熬了一次还有第二次,比赛重打了,今天发挥正常,水平有限,原本给自己的目标就是签到签完,所以还是挺满意的,唯一有一点不满意的就是一道题一个很简单的问题,一开始考虑了,改完代码不记得了,WA了好几次,硬是看不出错来,心态快裂开了。

1002题

题目
Computational geometry and computer graphics are such hard parts of computer science that Kanade can’t manage them. So she doesn’t want to learn CG anymore. She goes to play basketball instead.

The only essential equipment in a basketball game is the ball and the hoop — a flat, rectangular backboard with a basket. We describe the hoop with a side view. Ignoring the thickness, the backboard is considered as a segment parallel to the y-axis, and the basket is considered as a segment parallel to the x-axis. The right end of the basket is connected to the backboard.

To simplify the model, we consider a basketball as a mass point. Taking only gravity into consideration, if we ignore the basket and the backboard, the trajectory of basketball will be a parabola y=ax2+bx+c with a<0. But the basketball is likely to hit the backboard, resulting in a change in trajectory. We consider the collision between a basketball and the backboard (including the endpoints) as a perfectly elastic collision, which means the velocity on the x-axis of the basketball will be reversed, and the velocity on the y-axis will remain the same. We ignore the court floor in this problem.

If the basketball passes through the basket (excluding the endpoints) from top to bottom, we consider the shoot is a goal. Once the basketball touches either of the endpoints of the basket, which means it hits the rim, the basketball will be bounced away and cannot make a goal. In addition, according to the rule, a basketball cannot pass through the basket from bottom to top, or it is a violation and cannot be counted as a goal.

Kanade knows the value of a,b,c and the position of the backboard and basket. She would like to know whether the shoot will be a goal if the basketball starts from x=-1145141919810 and moves in the positive direction of the x-axis.
输入
The first line of input contains one integer T (1≤T≤500), indicating the number of test cases.

For each test case, the first line contains three integers a,b,c (a<0), indicating the parameters of the parabola.

The second line of each test case contains five integers x0, x1, y0, y1, y2,x0< x1,y1< y0< y2, indicating that the two endpoints of the basket are (x0,y0) and (x1,y0) , and the two endpoints of the backboard are (x1,y1) and (x1,y2).

It is guaranteed that the absolute value of all integers in the input won’t exceed 104.

翻译一下,大致意思是一个人不想学习了打算去打篮球,将篮球框理想化为一段线段,篮球板抽象为一段线段,给你一个抛物线的函数,篮球框和篮球板来两条线段的共四个端点的坐标,让你判断是否能进球。(进球有两种情况,直接投进和打到板上反弹后投进,反弹是弹性碰撞,从框下进框上出,即反向投入是无效的。打到端点会被反弹走,也进不了球。)

输出
给定每个例子,输出是否能够得分,投中就输出 Yes,不中就输出No。

Sample Input:
4
-1 4 5
3 5 6 5 8
-2 -3 3
-1 0 2 1 4
-1 -9 19
8 10 6 5 8
-1 9 19
8 10 4 3 6

Sample Output:
Yes
Yes
No
No

Hint:
The samples are shown as follows. Segment AB represents the basket, and segment CD represents the backboard.

思路:
这道题其实挺简单的,但是还是错了好几次,只要分两种情况就好了,一种是直接投中,一种是反弹后投中。
手写了一下思路
代码

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c;
ll f(ll x)
{
	return a*x*x+b*x+c;
}
int main()
{
	ll t;
	scanf("%lld",&t);
	while(t--)
	{
		ll x0,x1,y0,y1,y2;
		scanf("%lld%lld%lld",&a,&b,&c);
		scanf("%lld%lld%lld%lld%lld",&x0,&x1,&y0,&y1,&y2);
		if((f(x0)>y0&&f(x1)<y0)||(f(x0)>y0&&f(2*x1-x0)<y0&&f(x1)<=y2&&f(x1)>y0))
		printf("Yes\n");
		else
		printf("No\n");
	}
	return 0;
}
1004题

由于题目直接复制过来会出现一些错误,所以就直接放截图了。
在这里插入图片描述
在这里插入图片描述
思路:
这道题应该是实至名归的签到题,正确率和通过的人数都高,题目也很简单,就是给一个x,让你判断,x后面的连续的两个质数(比如11和13是连续的质数,两个数之间不存在其他质数)相加再整除2,判断这个结果是不是质数。
咋一看好像也不是很简单,但其实,因为是两个连续的质数,两个质数之间是不存在质数的,所以除了x = 1的时候,这个时候由于两个质数只差了1,整除二的结果就是小的那个质数。其他的情况,两个数相加整除2就一定是两个质数之间的数,那么这个数一定不是质数,又由于质数一定是奇数,所以两个相加一定是被整除的,除了x = 1的情况,其他情况两个质数相加一定落在他们中间。所以写一个判断,如果 x = 1 就输出Yes,否则就输出 No。

1006题

接下来这题真的折磨之王,代码很正确,案例也过了,我认为自己数据大小也考虑了,也不存在什么特殊情况了,感觉万无一失了,但!就是有问题!白拿了好几次罚时,最后!发现自己答案没有取模!直接原地爆炸,代码耗了很久,改代码耗了差不多一样的时间,就因为没有取模!!!—_— 直接裂开。
来,上题目。
在这里插入图片描述
思路
这道题应该是用了dp来做的。时间有点晚了,先贴个代码,下次再讲讲思路好了。
前来更新,首先我将题目中给定的字符串称为x,将要进行对比的字符串称为s,将s数组从头开始遍历,将每个s数组中的字符与整个x数组进行比较,当该字符与x数组中某个字符第一次相匹配了,我们先假定已经知道x数组的该字符前一段在s数组中已经找到过n次了,那么从头开始到该字符的这一段在s数组中就有n种组合已存在,所以每匹配到一个字符,就是前一个字符的可能性再加上该字符已有的可能性。但是s中的每个字符如果和从头开始和x字符数组相匹配,如果是两个连续相同的字符,就会导致x数组中的这两个字符的位置都加前一个字符的可能性,那如果这个字符是第一次出现呢,很显然相同的第二个字符已出现匹配的可能性为0,但代码实现会不等于0,所以我们要从后往前匹配。
而后面的a呢,由于个数只要大于0就好,所以有n个a,就有2的n次减1的可能性。
代码

# include<bits/stdc++.h>
using namespace std;
const int a=998244353;
long long cal(long long int x,long long int y){
	long long int ans=1;
	while(y){
		if(y&1) ans=ans*x%a;
		x=x*x%a;
		y>>=1;
	}
	return ans-1;
}
int main(){
	long long int t,count=0,sum=0,count1=0;
	scanf("%lld",&t);
	char s[1001000],x[]="nunhehheh";
	getchar();
	while(t--){
		int dp[20]={0};
		count=0;
		count1=0;
		sum=0;
		gets(s);
		dp[0]=1;
		int ls=strlen(s);
		int lx=strlen(x);
		for(int i=0;i<ls;i++){
			if(s[i]=='a')
			count1++;
		}
		for(int i=0;i<ls;i++){
			if(s[i]=='a'){
				count++;
			}
			for(int j=lx-1;j>=0;j--){
				if(x[j]==s[i]){
					dp[j+1]=(dp[j+1]+dp[j])%a;
					if(j==(lx-1)&&dp[j]!=0){
						sum=(sum+dp[j]*cal(2,count1-count)%a)%a;
					}
				}
			}
		}
		printf("%lld\n",sum);
	}
	return 0;
}
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值