“今晚cf来打吗?”
恍惊起,只剩15min,立刻冲出实验室,狂奔半个校园冲向校门口,骑上自行车赶往寝室
重新打开电脑的那一刻,精疲力竭,若灵魂出窍,然已经迟到了5min多,不顾室友一脸惊愕的眼光,赶紧开始看题
塞翁失马,焉知非福,今晚状态异常的好,a题水水,在惊魂未定中飘过,b题定下心,推推公式,一遍就过,瞬间升至朋友圈榜首,心中突然有了动力,最后c,推出了自己都不敢相信的结论,为保险起见,还写个数据生成器测试了半天,确保万无一失后,压哨交题,睡觉,一觉起来,狂升100+,或许这就是奇遇吧
A. Arpa and a research in Mexican wave
思路:水题,没的说,分三段求公式,算是缓一缓气吧
/*
Author Owen_Q
*/
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int main()
{
int n,k,t;
while(scanf("%d%d%d",&n,&k,&t)!=EOF)
{
if(t<k)
{
printf("%d\n",t);
}
else if(t>n)
{
printf("%d\n",n+k-t);
}
else
{
printf("%d\n",k);
}
}
return 0;
}
B. Arpa and an exam about geometry
思路:三角形外心作为旋转轴,确保两点相等即可,注意三点共线无法得到外心,特判即可
这题过的特别快,似乎难倒了不少人,也算是今晚成功的一大因素吧
/*
Author Owen_Q
*/
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int main()
{
long long ax,ay,bx,by,cx,cy;
while(scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&ax,&ay,&bx,&by,&cx,&cy)!=EOF)
{
if(((ax-bx)*(ax-bx)+(ay-by)*(ay-by))==((bx-cx)*(bx-cx)+(by-cy)*(by-cy)))
{
if((2*bx==ax+cx)&&(2*by==ay+cy))
{
printf("No\n");
}
else
{
printf("Yes\n");
}
}
else
{
printf("No\n");
}
}
return 0;
}
C. Five Dimensional Points
思路:O(n^3)枚举,O(1e9)感觉会tle,猛然发现n>11时全为0,瞬间降为O(1000)的时间复杂度,由于不敢确定,证明,数据生成器验证花了大量时间,否则这次应该还有提升空间。
最后非常玄学的是,队友O(1e9)的算法好像也过了,这个确实有点醉
/*
Author Owen_Q
*/
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3+10;
const double pi = 3.1415926536;
const double cg = 180.0 / pi;
int a[maxn],b[maxn],c[maxn],d[maxn],e[maxn];
vector <int> good;
bool calangle(int x,int y,int z)
{
int x1 = a[y]-a[x];
int x2 = b[y]-b[x];
int x3 = c[y]-c[x];
int x4 = d[y]-d[x];
int x5 = e[y]-e[x];
int y1 = a[z]-a[x];
int y2 = b[z]-b[x];
int y3 = c[z]-c[x];
int y4 = d[z]-d[x];
int y5 = e[z]-e[x];
double xy = double(x1*y1+x2*y2+x3*y3+x4*y4+x5*y5);
double xx = sqrt(double(x1*x1+x2*x2+x3*x3+x4*x4+x5*x5));
double yy = sqrt(double(y1*y1+y2*y2+y3*y3+y4*y4+y5*y5));
double angle = acos(xy/(xx*yy));
//cout <<x<<"*"<<y<<"*"<<z<<"*"<<xx<<"*"<<yy<<"*"<<xy<<"*"<<angle*cg << endl;
if(angle*cg+1e-9<90)
{
//cout << "&&" << endl;
return false;
}
else
{
//cout << "$$" << endl;
return true;
}
}
int main()
{
int n;
//cout << asin(0.5)*cg<<endl;
while(scanf("%d",&n)!=EOF)
{
for(int i=1;i<=n;i++)
{
scanf("%d%d%d%d%d",&a[i],&b[i],&c[i],&d[i],&e[i]);
}
if(n>11)
{
printf("%d\n",0);
}
else
{
int sum = 0;
good.clear();
bool isgood;
for(int i=1;i<=n;i++)
{
isgood = true;
for(int j=1;isgood&&j<n;j++)
{
if(j==i)
{
continue;
}
for(int k=j+1;isgood&&k<=n;k++)
{
if(k==i)
{
continue;
}
isgood = calangle(i,j,k);
}
}
if(isgood)
{
good.push_back(i);
sum++;
}
}
sort(good.begin(),good.end());
printf("%d\n",sum);
if(sum>0)
{
int len = good.size();
for(int i=0;i<len-1;i++)
{
printf("%d ",good[i]);
}
printf("%d\n",good[len-1]);
}
}
}
return 0;
}
无论如何,还是纪念一下吧,纯数学场,涨粉奇遇记
icpc就要开始了,加油吧