Eqs
Title Abstract: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 (*), gives A1,a2,a3,a4,a5. Ai belongs to [ -50,50].
Ask how many sequences x1,x2,x3,x4,x5, Xi belongs to [ -50,50]-{0}.
Idea: Binary enumeration + binary lookup
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6#include <map>7 using namespacestd;8typedefLong LongLL;9 Const intms= -;Ten Const intSize=10000; One A intHash[size]; - intCNT; - the intMain () - { - intA1,a2,a3,a4,a5; - while(SCANF ("%d%d%d%d%d", &A1,&A2,&A3,&A4,&A5)! =EOF) + { -Cnt=0; + for(inti=-ms;i<=ms;i++) A for(intj=-ms;j<=ms;j++) at { - if(i==0|| j==0) - Continue; - intt=a1*i*i*i+a2*j*j*J; -hash[cnt++]=T; - } inSort (hash,hash+CNT); - intans=0; to for(inti=-ms;i<=ms;i++) + for(intj=-ms;j<=ms;j++) - for(intk=-ms;k<=ms;k++) the { * if(i==0|| j==0|| k==0) $ Continue;Panax Notoginseng intt=a3*i*i*i+a4*j*j*j+a5*k*k*K; -Ans+=upper_bound (hash,hash+cnt,-t)-lower_bound (hash,hash+cnt,-t); the } +printf"%d\n", ans); A } the return 0; +}
EQS Binary Enumeration + Two-point search for flood problems