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 这种题目。。直接暴力吧
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void write(LL a)
{
if (a<){printf("-");a=-a;}
if (a>=)write(a/);
putchar(a%+'');
}
inline void writeln(LL a){write(a);printf("\n");}
int n,m,tot,ans;
int p[];
int mrk[];
int main()
{
scanf("%d",&n);
for (int i=;i<=;i++)p[i]=i*i*i,mrk[p[i]]=i;
for (int i=;i<=;i++)
{
if (tot+p[i]>n)break;
tot+=p[i];
for (int j=i;j<=;j++)
{
if(tot+p[j]>n)break;
tot+=p[j];
for (int k=j;k<=;k++)
{
if (tot+p[k]>n)break;
tot+=p[k];
for (int l=k;l<=;l++)
{
if (tot+p[l]>n)break;
tot+=p[l];
for (int m=l;m<=;m++)
if (tot+p[m]==n)ans++;
tot-=p[l];
}
tot-=p[k];
}
tot-=p[j];
}
tot-=p[i];
}
printf("%d\n",ans);
}
Spoj BOKAM143SOU
Spoj-BOKAM143SOU Checking cubes.的更多相关文章
- CentOS:ECDSA host key "ip地址" for has changed and you have requested strict checking(转)
原文地址:http://blog.csdn.net/ausboyue/article/details/52775281 Linux SSH命令错误:ECDSA host key "ip地址& ...
- BZOJ 2588: Spoj 10628. Count on a tree [树上主席树]
2588: Spoj 10628. Count on a tree Time Limit: 12 Sec Memory Limit: 128 MBSubmit: 5217 Solved: 1233 ...
- Sensitive directory/file Integrity Monitoring and Checking
catalogue . OSSEC . HashSentry: Host-Based IDS in Python . Afick . 检测流程 1. OSSEC OSSEC is an Open So ...
- SPOJ DQUERY D-query(主席树)
题目 Source http://www.spoj.com/problems/DQUERY/en/ Description Given a sequence of n numbers a1, a2, ...
- 水泡动画模拟(Marching Cubes)
Marching Cubes算法是三维离散数据场中提取等值面的经典算法,其主要应用于医学领域的可视化场景,例如CT扫描和MRI扫描的3D重建等. 算法主要的思想是在三维离散数据场中通过线性插值来逼近等 ...
- SPOJ GSS3 Can you answer these queries III[线段树]
SPOJ - GSS3 Can you answer these queries III Description You are given a sequence A of N (N <= 50 ...
- Codeforces525E Anya and Cubes(双向搜索)
题目 Source http://codeforces.com/contest/525/problem/E Description Anya loves to fold and stick. Toda ...
- 【填坑向】spoj COT/bzoj2588 Count on a tree
这题是学主席树的时候就想写的,,, 但是当时没写(懒) 现在来填坑 = =日常调半天lca(考虑以后背板) 主席树还是蛮好写的,但是代码出现重复,不太好,导致调试的时候心里没底(虽然事实证明主席树部分 ...
- 高并发下MySQL出现checking permissions
在某些数据访问层框架中,会使用show full tables from test like 'demo',来检查数据库的状态.当数据库中表的数量较少时,并没有出现严重的问题.但是当数据库中的表数量多 ...
随机推荐
- javascript 写一个随机范围整数的思路
const {random} = Math; //返回 [min,max] 的随机值 //[0,1) * (max - min + 1) => [0,max-min+1) //[0,max-mi ...
- 268. Missing Number@python
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...
- 【Java_基础】空串、空格串、null的区别
1.表示的区别 string str1 = ""; //空串 str1.length() 等于 0 string str2 = " "; / ...
- numpy模块(对矩阵的处理,ndarray对象)
6.12自我总结 一.numpy模块 import numpy as np约定俗称要把他变成np 1.模块官方文档地址 https://docs.scipy.org/doc/numpy/referen ...
- [学习笔记]一个实例理解Lingo的灵敏性分析
一个实例理解Lingo的灵敏性分析 线性规划问题的三个重要概念: 最优解就是反应取得最优值的决策变量所对应的向量. 最优基就是最优单纯形表的基本变量所对应的系数矩阵如果其行列式是非 ...
- Ubuntu 清理卸载残留文件
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
- java 邮箱验证
1.需要加入发送邮件的mail.jar: http://www.oracle.com/technetwork/java/javamail/index-138643.html 2.将字符串通过MD5进行 ...
- printf和scanf中的%控制
输出函数的格式字符:printf(): 附加的格式说明符: 格式输入函数的格式控制符:scanf(): 版权声明:本文为博主原创文章,未经博主允许不得转载.
- 项目-开发手机app
一. 安装Hbuilder,和夜神安卓模拟器 注:夜神模拟器,如过windows中安装了hyper-v,需要卸载,不然会死机 二. Hbuilder简介 官网:http://www.dcloud.i ...
- SQLserver查看某个视图的创建语句
1.已经创建好的视图,查看视图创建时的源码 sp_helptext '视图名' 如下: sp_helptext 'V_user' 方式2: sa账户登录SQLserver,选择视图---右键---- ...