Educational Codeforces Round 57 (Rated for Div. 2) A(读题)B(规律)C(数学几何)

A. Find Divisible(读题)

题目链接:https://codeforces.com/contest/1096/problem/A

题目大意:T组数据,每组数据在[l,r]范围内找两个值a,b满足:a<b&&b整除a

思路:a=l,b=2*l

AC:

int main()
{
    std::ios::sync_with_stdio(false);
    int T;
    while(cin>>T)
    {
    	while(T--)
    	{
		    int l,r;
		    cin>>l>>r;
		    cout<<l<<" "<<2*l<<endl;
		}
	}
}

B. Substring Removal(规律)

题目链接:https://codeforces.com/contest/1096/problem/B

题目大意:给你一个字符串,让你删掉一个连续区间内的元素,使剩下的字符串的元素种类都一样,问有多少种删法。

思路:因为删除的是一个连续区间,因此,我们只用考虑前面有多少个重复的和后面有多少个重复的就行了,如果前面的和后面的元素一样,再加上就行了。

AC:

char s[MAXN];

int main()
{
    std::ios::sync_with_stdio(false);
    int l;
    while(cin>>l)
    {
    	clean(s,'\0');
    	cin>>s;
    	ll L=1,R=1;
    	for(int i=1;i<l;++i)
    	{
    		if(s[i]!=s[i-1])
    			break;
    		L++;
		}
		for(int i=l-1;i>=0;--i)
		{
			if(s[i-1]!=s[i])
				break;
			R++;
		}
		ll ans;
//		ans=(MAXN-10)*(MAXN-9)/2;
//		cout<<ans%mod<<endl;
		if(0+L<l-R+1)
		{//s���в�ͬ���ַ� 
			if(s[0]==s[l-1])//ǰ����ַ���� 
				ans=(L+1)*(R+1);
			else
				ans=L+R+1;
		}
		else//s�ж���һ���ַ� 
			ans=(1+l)*l/2;
		cout<<ans%mod<<endl;
	}
}

C. Polygon for the Angle(规律,几何)

题目链接:https://codeforces.com/contest/1096/problem/C

题目大意:为表达角度m,由正n边形组成的多边形,正好能够表达出的角度,问最小的n是多少

思路:其实这个退一下就知道了,多变形堪称圆,圆心角和对应的弧是一半。然后跟据圆心角就能推出多边形的点了

扫描二维码关注公众号,回复: 5080939 查看本文章

AC:

const int MAXN=2e5+10;
const int INF=0x3f3f3f3f;
const ll mod=998244353;
const double PI=acos(-1.0);

int main()
{
    std::ios::sync_with_stdio(false);
    int T;
    while(cin>>T)
    {
    	while(T--)
    	{
    		int n;
    		cin>>n;
    		n=n*2; //178 * 2 = 356 
    		int ans=INF;
    		for(int i=1;i<=360;++i)
    		{//i����ȵĽǹ��ɵ� 2*n��  89*4=356 89���� 
    			if(n%i==0)
    			{//�ܱ�i���ǹ���,ÿ����n/i��  4�� 
    				if(360%(n/i)==0)
    				{//n/i���ܹ�����ʾ���� 
    					if(360/(n/i)-i>1)
						//cout<<i<<" "<<n/i<<" "<<360/(n/i)<<endl;
							ans=min(ans,360/(n/i));
					}
				}
			}
			cout<<ans<<endl;
		}
	}
}

猜你喜欢

转载自blog.csdn.net/qq_40482358/article/details/86656390