Spoj-BOKAM143SOU Checking cubes.

Given a integer N. Find number of possible ways to represent N as a sum of at most five cubes.

 

Input

First line contains N.

1<=N<=125000.

Output

Output the result

Example

Input:
64

Output:
2

这种题目。。直接暴力吧
 1 #include<cstdio>
 2 #include<iostream>
 3 #include<cstring>
 4 #include<cstdlib>
 5 #include<algorithm>
 6 #include<queue>
 7 #include<deque>
 8 #include<set>
 9 #include<map>
10 #include<ctime>
11 #define LL long long
12 #define inf 0x7ffffff
13 #define pa pair<int,int>
14 #define pi 3.1415926535897932384626433832795028841971
15 using namespace std;
16 inline LL read()
17 {
18     LL x=0,f=1;char ch=getchar();
19     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
20     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
21     return x*f;
22 }
23 inline void write(LL a)
24 {
25     if (a<0){printf("-");a=-a;}
26     if (a>=10)write(a/10);
27     putchar(a%10+'0');
28 }
29 inline void writeln(LL a){write(a);printf("\n");}
30 int n,m,tot,ans;
31 int p[51];
32 int mrk[125001];
33 int main()
34 {
35     scanf("%d",&n);
36     for (int i=1;i<=50;i++)p[i]=i*i*i,mrk[p[i]]=i;
37     for (int i=0;i<=50;i++)
38     {
39         if (tot+p[i]>n)break;
40         tot+=p[i];
41         for (int j=i;j<=50;j++)
42         {
43             if(tot+p[j]>n)break;
44             tot+=p[j];
45             for (int k=j;k<=50;k++)
46             {
47                 if (tot+p[k]>n)break;
48                 tot+=p[k];
49                 for (int l=k;l<=50;l++)
50                 {
51                     if (tot+p[l]>n)break;
52                     tot+=p[l];
53                     for (int m=l;m<=50;m++)
54                         if (tot+p[m]==n)ans++;
55                     tot-=p[l];
56                 }
57                 tot-=p[k];
58             }
59             tot-=p[j];
60         }
61         tot-=p[i];
62     }
63     printf("%d\n",ans);
64 }
Spoj BOKAM143SOU

 

转载于:https://www.cnblogs.com/zhber/p/7153131.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值