当前位置:网站首页>UCF (2022 summer team competition I)
UCF (2022 summer team competition I)
2022-07-06 05:14:00 【. Ashy.】
List of articles
B . Good Coin Denomination
Carelessness :
give n A sequence of , Ask whether each sequence meets Each element is at least twice as big as the previous one ( Apart from the first element ) This nature
direct simulation And then determine that will do
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
int n,t;
int a[N];
bool solve()
{
for(int i=2;i<=n;i++)
{
double k=(double)a[i]/(double)a[i-1];
if(k<2) return 0;
}
return 1;
}
int main()
{
cin>>t;
while(t--)
{
cin>>n;
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
if(solve()) puts("0");
else puts("1");
}
}
D . Matrix Transformation( State compression )
Carelessness :
Give a matrix , You can make adjacent elements at the same time Add 1 perhaps meanwhile reduce 1, Ask whether every element of the matrix is changed into 0
Ideas :
If the matrix is not processed , There are too many and complex states that a matrix can transfer , Do not know how to start , We can move the non-zero elements of the matrix to the right to the last column through two operations , That is, compress the two-dimensional matrix into one , Then continue to compress the elements of this column to a point according to this idea , This last point cannot be operated with other elements , This point is 0 Matrix can be operated , This point is not 0 , The matrix cannot be changed into 0 matrix
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
int t,n,m;
int a[51][51];
int main()
{
cin>>t;
while(t--)
{
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
scanf("%d",&a[i][j]);
if(j>1)
{
a[i][j]-=a[i][j-1];
}
}
}
for(int i=2;i<=n;i++)
{
a[i][m]-=a[i-1][m];
}
if(!a[n][m]) puts("0");
else puts("1");
}
}
reflection :
This problem starts from the state transition without a clue, and I don't know where to start , To gradually compress one dimension , Compress to a point , Very good idea , Accumulate
E,Cut the Cake! ( Plane geometry )
Carelessness :
Give a polygon use A straight line y = k To cut off , Find the circumference of the upper and lower parts of the cut
Ideas
First calculate the side length of the uncut part , Plus the side length of the public part , Then add the length of the cut part
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
int n,y;
int id[5];
struct node{
double x,y;
}a[20],n1[5],d[3];
int cntn,cnts,t;
double sum1,sum2;//sum1 On sum2 Next
// The formula for calculating the distance between two points
double dis(double x1,double y1,double x2,double y2)
{
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
// Calculation y = k The length of the cut part at the intersection with the figure
void solve(double x1,double y1,double x2,double y2)
{
double xx;
// According to the known two points, calculate the linear equation, bring in the ordinate, and calculate the abscissa
// Be careful x2=0 x1=x2 Two cases , Very important , The denominator cannot be 0
if(x2==0) xx=(y-y2)/((y1-y2)/x1);
else
if(x1==x2) xx=x1;
else xx=(y-((y1-(x1/x2)*y2)/(1-x1/x2)))/((y1-y2)/(x1-x2));
if(y1>y) sum1+=dis(xx,y,x1,y1);
else sum2+=dis(xx,y,x1,y1);
if(y2>y) sum1+=dis(xx,y,x2,y2);
else sum2+=dis(xx,y,x2,y2);
d[++cnts].x=xx;
d[cnts].y=y;
}
int main()
{
cin>>t;
while(t--)
{
cin>>n>>y;
cntn=0;cnts=0;
sum1=sum2=0;
for(int i=1;i<=n;i++) scanf("%lf %lf",&a[i].x,&a[i].y);
// Record two points on both sides of the split line
for(int i=1;i<n;i++)
{
if(a[i].y>y&&a[i+1].y<y||a[i].y<y&&a[i+1].y>y)
{
n1[++cntn].x=a[i].x;
n1[cntn].y=a[i].y;
id[cntn]=i;
n1[++cntn].x=a[i+1].x;
n1[cntn].y=a[i+1].y;
id[cntn]=i+1;
}
}
if(a[n].y>y&&a[1].y<y||a[n].y<y&&a[1].y>y)
{
n1[++cntn].x=a[n].x;
n1[cntn].y=a[n].y;
id[cntn]=n;
n1[++cntn].x=a[1].x;
n1[cntn].y=a[1].y;
id[cntn]=1;
}
// Calculate the length of the undivided part in turn according to the found points
int idd1=id[2];
int idd2;
if(idd1==n) idd2=1;
else idd2=idd1+1;
while(idd1!=id[3])
{
if(a[idd1].y>y)
sum1+=dis(a[idd1].x,a[idd1].y,a[idd2].x,a[idd2].y);
else
sum2+=dis(a[idd1].x,a[idd1].y,a[idd2].x,a[idd2].y);
idd1++;
if(idd1==n+1) idd1=1;
idd2=idd1+1;
if(idd1==n) idd2=1;
}
int idd3=id[4];
int idd4;
if(idd3==n) idd4=1;
else idd4=idd3+1;
while(idd3!=id[1])
{
if(a[idd3].y>y)
sum1+=dis(a[idd3].x,a[idd3].y,a[idd4].x,a[idd4].y);
else
sum2+=dis(a[idd3].x,a[idd3].y,a[idd4].x,a[idd4].y);
idd3++;
if(idd3==n+1) idd3=1;
idd4=idd3+1;
if(idd3==n) idd4=1;
}
// Add the length of the divided part
solve(a[id[1]].x,a[id[1]].y,a[id[2]].x,a[id[2]].y);
solve(a[id[3]].x,a[id[3]].y,a[id[4]].x,a[id[4]].y);
// Add the length of the public part
sum1+=dis(d[1].x,d[1].y,d[2].x,d[2].y);
sum2+=dis(d[1].x,d[1].y,d[2].x,d[2].y);
// Output in order of size
printf("%.3lf %.3lf\n",min(sum1,sum2),max(sum1,sum2));
}
}
/* 1 3 5 0 10 0 0 10 0 */
reflection
Pay attention to The denominator is not 0 Is a very important condition , The denominator must not be 0
use while When writing a loop, you must pay attention to the conversion of loop conditions , Very important
边栏推荐
- L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
- 关于Unity Inspector上的一些常用技巧,一般用于编辑器扩展或者其他
- Hometown 20 years later (primary school exercises)
- Microblogging hot search stock selection strategy
- On the solution of es8316's audio burst
- Postman manage test cases
- 【OSPF 和 ISIS 在多路访问网络中对掩码的要求】
- Talking about the type and function of lens filter
- Drive development - the first helloddk
- EditorUtility. The role and application of setdirty in untiy
猜你喜欢

IPv6 comprehensive experiment

Leetcode dynamic planning day 16

Postman管理测试用例

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

麥斯克電子IPO被終止:曾擬募資8億 河南資產是股東

ORM aggregate query and native database operation

idea一键导包

Fiddler installed the certificate, or prompted that the certificate is invalid

Postman前置脚本-全局变量和环境变量

pix2pix:使用条件对抗网络的图像到图像转换
随机推荐
The kernel determines whether peripherals are attached to the I2C address
指针经典笔试题
UCF(2022暑期团队赛一)
Codeforces Round #804 (Div. 2)
行业专网对比公网,优势在哪儿?能满足什么特定要求?
Modbus protocol communication exception
Postman Association
yolov5 tensorrt加速
Chip debugging of es8316 of imx8mp
IPv6 comprehensive experiment
Postman前置脚本-全局变量和环境变量
图论的扩展
Hometown 20 years later (primary school exercises)
[NOIP2009 普及组] 分数线划定
Mysql高级篇学习总结9:创建索引、删除索引、降序索引、隐藏索引
Microblogging hot search stock selection strategy
Leetcode 186 Flip the word II in the string (2022.07.05)
ByteDance program yuan teaches you how to brush algorithm questions: I'm not afraid of the interviewer tearing the code
2021 robocom world robot developer competition - undergraduate group (semi-finals)
ISP learning (2)