Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:折半枚举大水题

Posted by louchiheng at 2016-04-02 13:18:03 on Problem 1840
In Reply To:折半枚举大水题 Posted by:13408100238 at 2015-05-10 20:42:07
> #include <iostream>
> #include <cstdio>
> #include <cstring>
> #include <cmath>
> #include <algorithm>
> #include <map>
> using namespace std;
> typedef long long LL;
> const int MS=50;
> const int SIZE=10000;
> 
> int hash[SIZE];
> int cnt;
> 
> int main()
> {
>     int a1,a2,a3,a4,a5;
>     while(scanf("%d%d%d%d%d",&a1,&a2,&a3,&a4,&a5)!=EOF)
>     {
>         cnt=0;
>         for(int i=-MS;i<=MS;i++)
>             for(int j=-MS;j<=MS;j++)
>         {
>             if(i==0||j==0)
>                 continue;
>             int t=a1*i*i*i+a2*j*j*j;
>             hash[cnt++]=t;
>         }
>         sort(hash,hash+cnt);
>         int ans=0;
>         for(int i=-MS;i<=MS;i++)
>             for(int j=-MS;j<=MS;j++)
>                 for(int k=-MS;k<=MS;k++)
>         {
>             if(i==0||j==0||k==0)
>                 continue;
>             int t=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);
>         }
>         printf("%d\n",ans);
>     }
>     return 0;
> }
> 
> 
> 
666

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator