Benches

Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

The city park of IT City contains n east to west paths and n north to south paths. Each east to west path crosses each north to south path, so there are n2 intersections.

The city funded purchase of five benches. To make it seems that there are many benches it was decided to place them on as many paths as possible. Obviously this requirement is satisfied by the following scheme: each bench is placed on a cross of paths and each path contains not more than one bench.

Help the park administration count the number of ways to place the benches.

Input

The only line of the input contains one integer n (5 ≤ n ≤ 100) — the number of east to west paths and north to south paths.

Output

Output one integer — the number of ways to place the benches.

Sample Input

Input
5
Output
120
题解:给公园装凳子,每个十字路口就一个,同行列就一个凳子,问多少种方法;
从行和列中分别选5个就是五个凳子安放的位置,然后5*5的格子有5!种方法;所以就是5!*C(n,5)*C(n,5);
ps:第一次用C#写一下,竟然就过了。。。跟C语言真像;
代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace 输入输出
{
class Program
{
static void Main(string[] args)
{
long ans = ;
int n;
string s = Console.ReadLine();
n = int.Parse(s);
for (int i = ; i <= ; i++)
{
ans = ans * (n - i + ) / i * (n - i + ) / i;
}
ans *= ;
Console.WriteLine("{0:d}", ans);
}
}
}
A rectangle

Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem.

A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit.

More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≤ x2 and y1 ≤ y2, then all cells having center coordinates (x, y) such that x1 ≤ x ≤ x2 and y1 ≤ y ≤ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1is divisible by 2.

Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map.

Help him implement counting of these units before painting.

Input

The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≤ x1 ≤ x2 ≤ 109,  - 109 ≤ y1 ≤ y2 ≤ 109) — the coordinates of the centers of two cells.

Output

Output one integer — the number of cells to be filled.

Sample Input

Input
1 1 5 5
Output
13
题解:给出两个点 x1 ≤ x ≤ x2 and y1 ≤ y ≤ y2,这些点为中心的6边型会被覆盖,问覆盖多少个,由于x轴差值必然是2的倍数,所以x轴覆盖的肯定是(x2-x1)/2+1;y则要考虑奇偶的问题;
很好推的;
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<string>
#include<vector>
using namespace std;
const int INF=0x3f3f3f3f;
#define SI(x) scanf("%d",&x)
#define PI(x) printf("%d",x)
#define P_ printf(" ")
#define mem(x,y) memset(x,y,sizeof(x))
typedef __int64 LL;
int main(){
LL x1,x2,y1,y2,x,y;
while(~scanf("%I64d%I64d%I64d%I64d",&x1,&y1,&x2,&y2)){
x=abs(x2-x1)/+;y=abs(y2-y1)/;
if(y1||y2)y++;
LL ans;
if(y==)ans=x;
else ans=x*y+(x-)*(y-);
printf("%I64d\n",ans);
}
return ;
}
Challenge Pennants

Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

Because of budget cuts one IT company established new non-financial reward system instead of bonuses.

Two kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a critical bug gets "I fixed a critical bug" pennant on his table. A man who suggested a new interesting feature gets "I suggested a new feature" pennant on his table.

Because of the limited budget of the new reward system only 5 "I fixed a critical bug" pennants and 3 "I suggested a new feature" pennants were bought.

In order to use these pennants for a long time they were made challenge ones. When a man fixes a new critical bug one of the earlier awarded "I fixed a critical bug" pennants is passed on to his table. When a man suggests a new interesting feature one of the earlier awarded "I suggested a new feature" pennants is passed on to his table.

One man can have several pennants of one type and of course he can have pennants of both types on his table. There are n tables in the IT company. Find the number of ways to place the pennants on these tables given that each pennant is situated on one of the tables and each table is big enough to contain any number of pennants.

Input

The only line of the input contains one integer n (1 ≤ n ≤ 500) — the number of tables in the IT company.

Output

Output one integer — the amount of ways to place the pennants on n tables.

Sample Input

Input
2
Output
24
题解:题目让在桌子上放两种奖状,一种有5个,一种有3个,n张桌子有几种方法,想了好久竟然是错的;
直接选桌子放广告就好了;
C#代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace ChallengePennants
{
class Program
{
static long Cout(int n,int t){
long x=;
for (int i = ; i <= t; i++) {
x = x * (n - i + ) / i;
}
return x;
}
static void Main(string[] args)
{
long ans = ;
int n;
string s = Console.ReadLine();
n = int.Parse(s);
ans *= Cout(n, ) + Cout(, ) * Cout(n, ) + Cout(n, ) * Cout(, ) * + * Cout(, ) * Cout(n, ) + Cout(n, );
ans *= Cout(n, ) + Cout(,)* Cout(n, ) + Cout(n, );
Console.WriteLine("{0:d}", ans);
}
}
}
Parking Lot

Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

To quickly hire highly skilled specialists one of the new IT City companies made an unprecedented move. Every employee was granted a car, and an employee can choose one of four different car makes.

The parking lot before the office consists of one line of (2n - 2) parking spaces. Unfortunately the total number of cars is greater than the parking lot capacity. Furthermore even amount of cars of each make is greater than the amount of parking spaces! That's why there are no free spaces on the parking lot ever.

Looking on the straight line of cars the company CEO thought that parking lot would be more beautiful if it contained exactly nsuccessive cars of the same make. Help the CEO determine the number of ways to fill the parking lot this way.

Input

The only line of the input contains one integer n (3 ≤ n ≤ 30) — the amount of successive cars of the same make.

Output

Output one integer — the number of ways to fill the parking lot by cars of four makes using the described way.

Sample Input

Input
3
Output
24

Hint

Let's denote car makes in the following way: A — Aston Martin, B — Bentley, M — Mercedes-Maybach, Z — Zaporozhets. For n = 3there are the following appropriate ways to fill the parking lot: AAAB AAAM AAAZ ABBB AMMM AZZZ BBBA BBBM BBBZ BAAA BMMM BZZZ MMMA MMMB MMMZ MAAA MBBB MZZZ ZZZA ZZZB ZZZM ZAAA ZBBB ZMMM

Originally it was planned to grant sport cars of Ferrari, Lamborghini, Maserati and Bugatti makes but this idea was renounced because it is impossible to drive these cars having small road clearance on the worn-down roads of IT City.

题解:排列组合题:题意是给放车,长度为2*n-2;中间有连续n辆车颜色相同;4种颜色;把这4辆连续颜色相同的车看成一辆,则有n-1辆,有一辆

跟旁边的颜色不同,考虑这个车在两端,以及中间的情况;则

ans=2*C(4,1)*C(3,1)*4^(n-3)+C(n-3,1)*C(4,1)*C(3,1)*C(3,1)*4^(n-4);

C#代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace ChallengePennants
{
class Program
{
static void Main(string[] args)
{
string s = Console.ReadLine();
int n = int.Parse(s);
if (n == )
{
Console.WriteLine("");
}
else {
long ans=;
int temp = n - ;
while (temp!=) {
ans *= ;
temp--;
}
ans *= (long) * (n - ) + ;
Console.WriteLine("{0:d}",ans);
}
}
}
}

cf公式专场-续的更多相关文章

  1. HBase之CF持久化系列(续3——完结篇)

    相信大家在看了该系列的前两篇文章就已经对其中的持久化有比较深入的了解.相对而言,本节内容只是对前两节的一个巩固.与持久化相对应的是打开文件并将其内容读入到内存变量中.而在本节,我就来介绍这一点. 本节 ...

  2. HBase之CF持久化系列(续2)

    正如上篇博文所说,在本节我将为大家带来StoreFlusher.finalizeWriter..如果大家没有看过我的上篇博文<HBase之CF持久化系列(续1)>,那我希望大家还是回去看一 ...

  3. HBase之CF持久化系列(续1)

    这一节本来打算讲解HRegion的初始化过程中一些比较复杂的流程.不过,考虑前面的博文做的铺垫并不够,因此,在这一节,我还是特意来介绍HBase的CF持久化.关于这个话题的整体流程性分析在博文< ...

  4. “玲珑杯”线上赛 Round #17 河南专场 A: Sin your life(和化积公式)

    传送门 题意 略 分析 首先将sin(x)+sin(y)+sin(z)h转化成\(2*sin(\frac{x+y}2)*cos(\frac{x-y}2)+sin(z)\),而cos(z)=cos(-z ...

  5. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  6. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  7. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

  8. CF(协同过滤算法)

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  9. OpenCV】透视变换 Perspective Transformation(续)

    载分 [OpenCV]透视变换 Perspective Transformation(续) 分类: [图像处理] [编程语言] 2014-05-27 09:39 2776人阅读 评论(13) 收藏 举 ...

随机推荐

  1. java中反射学习整理

    转载请注明:http://blog.csdn.net/j903829182/article/details/38405735 反射主要是指程序能够訪问.检測和改动它本身的状态或行为的一种能力. jav ...

  2. 设置Android设备在睡眠期间始终保持WLAN开启的代码实现

    MainActivity例如以下: package cc.ab; import android.os.Bundle; import android.provider.Settings; import ...

  3. 【二分答案】 【POJ3497】 【Northwestern Europe 2007】 Assemble 组装电脑

    Assemble Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3171   Accepted: 1013 Descript ...

  4. css之background的cover和contain的缩放背景图

    对于这两个属性,官网是这样解释的: contain 此时会保持图像的纵横比并将图像缩放成将适合背景定位区域的最大大小. 等比例缩放图象到垂直或者水平其中一项填满区域. cover 此时会保持图像的纵横 ...

  5. HTML5新增的主体元素和新增的非主体结构元素

    HTML5新增的主体元素 article元素 article元素表示文档.页面或应用程序中独立的.完整的.可以独自被外部引用的内容.它可以是一篇博客或者报刊中的文章,一篇论坛帖子.一段用户评论或独立的 ...

  6. Information seeking letter, hard copy version

    23 Roanoke Street Blacksburg, VA 24060 (540) 555-1123 K.Walker@vt.edu October 23, 20XY Mr. James G. ...

  7. 动态加载Ribbon功能区

    上下文选项卡对新UI的功能提供了极大的推进作用.当用户对某对象执行特定的任务时就会出现特定的选项卡.例如,在Excel中处理图表时,一个上下文选项卡提供用于图表处理的额外选项.本文将介绍创建和执行这些 ...

  8. 第二章实例:Android窗口菜单显示

    package test.main.cls; import com.example.popupwindow.R; import android.app.Activity; import android ...

  9. CREATE DATABASE建库语句详解

    原创地址:http://blog.csdn.net/guguda2008/article/details/5716939 一个完整的建库语句是类似这样的: IF DB_ID('TEST') IS NO ...

  10. 安装apache mysql 论坛(一)

    安装mysql: 注: yum文件配置: 检查配置文件: 启动:service mysqld start 查询表: apache安装 启动: 查看端口: 欢迎界面: 如果服务了4000次,会主动销毁, ...