📄 2547192_ac_3527ms_376k.cpp
字号:
#include <stdio.h>
#include <stdlib.h>
#define f(a) a*a*a
#define INIT (Hash *)malloc(sizeof(Hash))
typedef struct node
{
int app;
int num;
struct node *l, *r;
}Hash;
Hash *hash;
int mark;
void push(int t)
{
Hash *p, *q;
if(mark)
{
hash = INIT;
hash->num = t;hash->app = 1;
hash->l = NULL;hash->r = NULL;
mark = 0;
}
else
{
p = hash;
q = INIT;
q->app = 1;
q->num = t;
q->l = NULL;q->r = NULL;
while(p)
{
if(p->num>t)
{
if(p->l)
p = p->l;
else
{
p->l = q;
return ;
}
}
else
if(p->num<t)
{
if(p->r)
p = p->r;
else
{
p->r = q;
return ;
}
}
else
{
p->app++;
return ;
}
}
}
}
__int64 find(int t)
{
Hash *p;
p = hash;
while(p)
{
if(p->num<t)
p = p->r;
else
if(p->num>t)
p = p->l;
else
return p->app;
}
return 0;
}
int main()
{
int a1, a2, a3, a4, a5;
int x1, x2, x3, x4, x5;
int c1, c2, c3, c, t;
__int64 ans = 0;
scanf("%d%d%d%d%d",&a1,&a2,&a3,&a4,&a5);
mark = 1;
for(x4 = -50; x4 <= 50; x4++)
{
if(!x4)
continue;
for(x5 = -50; x5 <= 50; x5++)
{
if(x5)
{
t = a4*f(x4)+a5*f(x5);
push(t);
}
}
}
for(x1 = -50; x1 <= 50; x1++)
{
if(!x1)
continue;
c1 = a1*f(x1);
for(x2 = -50; x2 <= 50; x2++)
{
if(!x2)
continue;
c2 = a2*f(x2);
for(x3 = -50; x3 <= 50; x3++)
{
if(!x3)
continue;
c3 = a3*f(x3);
c = c1+c2+c3;
ans += find(c);
}
}
}
printf("%I64d\n",ans);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -