[GDKOI] Popularize Day 3 in 2021

[GDKOI] Popularize Day 3 in 2021

The first question is triangle similarity

Submit file: triangle.cpp
Input file: triangle.in
Output file: triangle.out
Time and space limitation: 1s, 512MB
You have already attended junior high school, I believe you will do this question.
Given two triangles, ask if the two triangles are similar.
The following definitions may be useful:
• If the three angles of two triangles are equal, then the two triangles are similar.
Input format The
input contains multiple sets of test data.
An integer T in the first line indicates the number of data groups.
Each group of data has six rows, and each row has two integers xi
and yi, which represent the coordinates of a vertex. Where (x1, y1), (x2 , y2), (x3, y3) represents a three
three vertices of the triangle, (x4, y4), ( x5, y5), (x6, y6) represents the second The three vertices of the triangle.
Output format
T lines are output, and each line outputs YES or NO to indicate whether the two triangles are similar.
Sample data
triangle.in
2
0 0
0 1
1 0
1 1
0 1
1 0
0 0
0 1
1 0
2 2
2 0
1 0
triangle.out
YES
NO
sample explanation
For the first set of data:
Page 2 of 7
GDKOI 2021 PJ Day3
For the second set of data:
Data range
For 40% of the data, |xi|, |yi
| ≤ 1000;
for 100% of the data , |xi|, |yi
| ≤ 109, 1 ≤ T ≤ 1000. Page 3 of 7
GDKOI 2021 PJ Day3

Second question, goodbye, cherry blossoms

Submit file: sakura.cpp
Input file: sakura.in
Output file: sakura.out
Time and space limitation: 1s, 512MB
Graduation season, in addition to watching seniors and seniors wearing suits, dresses, and beautiful skirts to take graduation photos, joking and saying goodbye to teachers and friends ,
Leave a message on the memorial book together , leaving a last good memory, the lower grade children who have not graduated should also pay attention to their final exam results.
There are n students in Xiaoxialong's class. She has a total of k subjects, and each subject's teacher's score is any real number between 0 and 100. The result is one subject and
one subject. On the i day, the score of the i-th subject will be issued. Xiaolong will know that she ranks ri in this subject in the class. Ranking r means that there are r 1 students
whose scores are strictly greater than hers, and students with the same score will have the same ranking.
Although this is a bad habit, Xiaolong always likes to predict her final ranking. For all 1 ≤ i ≤ k, you have to answer the
best and worst ranking of the sum of her previous i subject scores.
Input format The
two positive integers n, k in the first line indicate the number of students and examination subjects.
In the second row, k positive integers r1, · · ·, rk, indicate the ranking of each subject.
The output format
consists of k rows, each with two positive integers. The two integers in the i-th row respectively represent the best ranking and the worst ranking of the sum of the scores of the first i subjects.
Sample data
sakura.in
6 2
3 5
sakura.out
3 3
2 6
Sample explanation
After the first subject is scored, because there is only 1 subject, the total ranking is equal to the ranking of this subject, which is 3;
after the second subject is scored, the score that can make the small shrimp cage rank 2 is
Xiaoxi 1 students students students cage 2 3 1 5 students students section 4 859092838180
2 section 787,081,808,079
out 163 160,173,163,161,159
can shrimp cage as a ranking score was 6
Little shrimp cage classmate 1 classmate 2 classmate 3 classmate 4 classmate 5 first subject 90 88 86 92 93 90
second subject 90 100 95 89 92 95
total score 180 188 181 181 185 185
does not exist that makes the small shrimp cage rank 1 .
Data range
For 20% of the data, 1 ≤ n, k ≤ 3, the teacher will only give five integer scores of 20, 40, 60, 80, 100;
Page 4 of 7
GDKOI 2021 PJ Day3
for 60 % Of data, 1 ≤ n, k ≤ 10000;
for 100% of data, 1 ≤ n ≤ 109, 1 ≤ k ≤ 105, guarantee 1 ≤ ri ≤ n.
This question has partial points. If only one of the best ranking and the worst ranking output is completely correct, you can get half of the score
for the data point . Therefore, in order to maximize the player's score, it is recommended to output k lines anyway, with two integers per line.
Page 5 of 7
GDKOI 2021 PJ Day3

The third topic number theory

Submit file: number.cpp
Input file: number.in
Output file: number.out
Time and space limitation: 1s, 512MB
Define the number theory function λ(n) as:
• Let the prime factorization of n be n = ∏ pei i, then λ (n) = (1)
∑ei
such as λ(4) = 1, λ(2) = 1, λ(1) = 1.
Your task is to find:
∑nk=1
∑i|k ∑j|i λ(i)λ(j) The
input format is
one line and an integer n.
The output format is
one line, an integer, which represents the result after the answer is modulo 998244353.
Sample data
number.in number.out
10 13
100000 164038
10000000000 477285001
Data range
For 20% of data, n ≤ 100;
for 60% of data, n ≤ 2 × 105;
for all data, n ≤ 1012. Page 6 of 7
GDKOI 2021 PJ Day3

Fourth question good sequence

Submit file: sequence.cpp
Input file: sequence.in
Output file: sequence.out
Time space limitation: 1s, 512MB It
is good to define a sequence A of length n, if and only if for any number i(1 ≤ i ≤ n), the sum of the first i numbers of the A sequence is greater
than or equal to the sum of the i numbers after the A sequence.
Formally speaking, if we remember lsumk = ∑ki=1
Ai
, rsumk = ∑ni=n k+1
Ai, then the sequence A is good if and only if:
∀1 ≤ k ≤ n, lsumk ≥ rsumk
now gives Given a number n, if the limit is 0 ≤ Ai ≤ n, how many good sequences A of length n are there?
The input format is
one line, an integer n.
The output format is
one line, an integer, which represents the result after the answer is modulo 998244353.
Sample data
sequence.in sequence.out
2 6
4 290
Sample explanation
For sample 1, (0, 0),(1, 0),(2, 0),(1, 1),(2, 1) ,(2, 0) are all legal schemes.
Data range
For 30% of the data, n ≤ 10;
for 50% of the data, n ≤ 16;
for 70% of the data, n ≤ 50;
For 100% data, n ≤ 100;

Code

T1

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long gcd(long long a,long long b)
{
    
    
	long long r;
	for(r=a%b;r;a=b,b=r,r=a%b);
	return b;
}
int main()
{
    
    
	freopen("triangle.in","r",stdin);
	freopen("triangle.out","w",stdout);
	long long x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,T,tem,i;
	long long b1[4],b2[4];
	for(scanf("%lld",&T);T;T--)
	{
    
    
		scanf("%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4,&x5,&y5,&x6,&y6);
		b1[0]=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
		b1[1]=(x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
		b1[2]=(x3-x2)*(x3-x2)+(y3-y2)*(y3-y2);
		b2[0]=(x4-x5)*(x4-x5)+(y4-y5)*(y4-y5);
		b2[1]=(x4-x6)*(x4-x6)+(y4-y6)*(y4-y6);
		b2[2]=(x6-x5)*(x6-x5)+(y6-y5)*(y6-y5);
		sort(b1,b1+3);
		sort(b2,b2+3);
		for(i=0;i<3;i++)
		{
    
    
			tem=gcd(b1[i],b2[i]);
			b1[i]/=tem;
			b2[i]/=tem;
		}
		if(b1[0]==b1[1]&&b1[1]==b1[2]&&b2[0]==b2[1]&&b2[1]==b2[2])
			printf("YES\n");
		else
			printf("NO\n");
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}

T2

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    
    
	freopen("sakura.in","r",stdin);
	freopen("sakura.out","w",stdout);
	long long n,k,r,good=0,bad=0;
	for(scanf("%lld%lld",&n,&k);k;k--)
	{
    
    
		scanf("%lld",&r);
		good+=n-r,bad+=r-1;
		printf("%lld %lld\n",max(n-good,(long long)(1)),min(bad+1,n));
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}

T3

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
    
    
	freopen("number.in","r",stdin);
	freopen("number.out","w",stdout);
	long long n,i,ans=0;
	scanf("%lld",&n);
	for(i=1;i*i<=n;ans=(n/(i*i)%998244353+ans)%998244353,i++);
	printf("%lld",ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}

T4

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const long long mods=998244353;
long long f[101][10001];
long long mydogabs(long long x)
{
    
    
	if(x<0)return -x;
	return x;
}
int main()
{
    
    
	freopen("sequence.in","r",stdin);
	freopen("sequence.out","w",stdout);
	long long n,i,j,k,ans=0;
	scanf("%lld",&n);
	for(f[0][0]=1,i=1;i<=n>>1;i++)
		for(j=0;j<=i*n;j++)
			for(f[i][j]=0,k=max(j-n,(long long)(0));k<=j+n;k++)
				f[i][j]=(f[i][j]+(1ll*(n+1-mydogabs(j-k))%mods*f[i-1][k]%mods))%mods;
	for(i=0;i<=(n*n)>>1;ans=(ans+f[n>>1][i])%mods,i++);
	if(n&1)ans=(ans*(1ll*(n+1)%mods))%mods;
	printf("%lld",ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Guess you like

Origin blog.csdn.net/weixin_46975572/article/details/115371883