Problem J

(2/3/4)-D Sqr/Rects/Cubes/Boxes?

Input: standard input

Output: standard output

Time Limit: 2 seconds

You can see a (4x4) grid below. Can you tell me how many squares and rectangles are hidden there? You can assume that squares are not rectangles. Perhaps one can count it by hand but can you count it for a (100x100) grid or a (10000x10000) grid. Can you do it for higher dimensions? That is can you count how many cubes or boxes of different size are there in a (10x10x10) sized cube or how many hyper-cubes or hyper-boxes of different size are there in a four-dimensional (5x5x5x5) sized hypercube. Remember that your program needs to be very efficient. You can assume that squares are not rectangles, cubes are not boxes and hyper-cubes are not hyper-boxes.

   

Fig: A 4x4 Grid

Fig: A 4x4x4 Cube

 

Input

The input contains one integer N (0<=N<=100) in each line, which is the length of one side of the grid or cube or hypercube. As for the example above the value of N is 4. There may be as many as 100 lines of input.

Output

For each line of input, output six integers S2, R2, S3, R3, S4, R4 in a single line where S2 means no of squares of different size in ( NxN) two-dimensional grid, R2 means no of rectangles of different size in (NxN) two-dimensional grid. S3, R3, S4, R4 means similar cases in higher dimensions as described before.

 

Sample Input:

1
2
3

Sample Output:

1 0 1 0 1 0
5 4 9 18 17 64
14 22 36 180 98 1198

 #include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
long long s2=, r2=, s3=, r3=, s4=, r4=;
long long m=n*(n+)/;
for(int i=;i<=n;i++)
{
s2=s2+i*i;
s3=s3+i*i*i;
s4=s4+i*i*i*i;
}
for(int i=;i<=n;i++)
{
r2=m*m-s2;
r3=m*m*m-s3;
r4=m*m*m*m-s4;
}
printf("%lld %lld %lld %lld %lld %lld\n",s2,r2,s3,r3,s4,r4);
}
return ;
}

UVA 10177 Sqr/Rects/Cubes/Boxes?的更多相关文章

  1. UVA 10733 - The Colored Cubes(Ploya)

    UVA 10733 - The Colored Cubes 题目链接 题意:一个立方体.n种颜色,问能涂成多少不同立方体 思路:Ploya求解,正方体相应24种不同旋转一一计算出循环个数就可以.和 U ...

  2. uva 10051 Tower of Cubes(DAG最长路)

    题目连接:10051 - Tower of Cubes 题目大意:有n个正方体,从序号1~n, 对应的每个立方体的6个面分别有它的颜色(用数字给出),现在想要将立方体堆成塔,并且上面的立方体的序号要小 ...

  3. uva 10733 The Colored Cubes<polya定理>

    链接:http://uva.onlinejudge.org/external/107/10733.pdf 题意: N 种颜色可以涂成多少种立方体~ 思路: 使正六面体保持不变的运动群总共有: 1.不变 ...

  4. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  5. (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO

    http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...

  6. ACM训练计划step 1 [非原创]

    (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成 ...

  7. 算法竞赛入门经典+挑战编程+USACO

    下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...

  8. caffe_实战之两个简单的例子(物体分类和人脸检测)

    一.物体分类: 这里使用的是caffe官网中自带的例子,我这里主要是对代码的解释~ 首先导入一些必要的库: import caffe import numpy as np import matplot ...

  9. 用caffe一步一步实现人脸检测

    学习深度学习已有一段时间了,总想着拿它做点什么,今天终于完成了一个基于caffe的人脸检测,这篇博文将告诉你怎样通过caffe一步步实现人脸检测.本文主要参考唐宇迪老师的教程,在这里感谢老师的辛勤付出 ...

随机推荐

  1. ORACLE表空间查询和管理【转】

    红色是自由指定的~~--查询表空间SELECT D.TABLESPACE_NAME,       SPACE "SUM_SPACE(M)",       SPACE - NVL(F ...

  2. pom可以过滤resource 下的文件

  3. eclipse安装阿里代码扫描插件

    1.首先打开eclipse软件,点击工具栏上的Help,选择Install New Soft进行安装新的插件. 2.进入插件安装界面,点击Add,弹出插件地址填写界面,也可以直接在市场上搜索关键字al ...

  4. WPF中ListBox的绑定

    WPF中列表式控件派生自ItemsControl类,继承了ItemsSource属性.ItemsSource属性可以接收一个IEnumerable接口派生类的实例作为自己的值(所有可被迭代遍历的集合都 ...

  5. lombok java代码助手

    是不一个不错的代码生成工具,可以实现将代码更精简,且不失代码效率的一种不错的方法 https://www.cnblogs.com/qnight/p/8997493.html 通过java bean v ...

  6. 24 The Go image package go图片包:图片包的基本原理

    The Go image package  go图片包:图片包的基本原理 21 September 2011 Introduction The image and image/color packag ...

  7. sqlserver中一些常用的函数总结

    去掉空格方面 LTRIM('内容'):去掉字符串左边的空格 RTRIM('内容'):去掉右边的空格 LTRIM(RTRIM('内容')):去掉字符串左边和右边的空格 REPLACE(‘内容’,' ', ...

  8. git ——本地项目上传到git

    1.(先进入项目文件夹)通过命令 git init 把这个目录变成git可以管理的仓库 git init 2.把文件添加到版本库中,使用命令 git add .添加到暂存区里面去,不要忘记后面的小数点 ...

  9. JAVA随笔(二)

    在函数传参时,double传给int是不行的,反过来可以.参数只能传值.当参数是字符串时,传递的只是串值:但对于数组来说,传递的是管理权,也就是指针 对象变量是对象管理者. cast转型:基本类型与对 ...

  10. High-Speed Tracking with Kernelized Correlation Filters(二)

          首先看看get_features函数.             首先判断是hog特征还是gray,分两种情况.             如果是hog特征,调用fhog函数,返回x,并将矩阵 ...