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. poj1664 放苹果(递归)

    转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://poj.org/problem?id=1664 ------ ...

  2. Linux转发性能评估与优化-转发瓶颈分析与解决方式(补遗)

    补遗 关于网络接收的软中断负载均衡,已经有了成熟的方案,可是该方案并不特别适合数据包转发,它对server的小包处理非常好.这就是RPS.我针对RPS做了一个patch.提升了其转发效率. 下面是我转 ...

  3. NTP-ntpdate:no server suitable for synchronization found

    NTP-ntpdate 问题处理 解决ntp的错误 no server suitable for synchronization found 当用ntpdate -d 来查询时会发现导致 no ser ...

  4. 判断Table表中是否含有某一列

    if (row.Table.Columns.Contains("DealRecord_GiftCost")) {     if (row["DealRecord_Gift ...

  5. SQL Server 2008 忘记sa密码的解决办法

    由于某些原因,sa和windows验证都不能登录 sql server,可以用独占模式,修改sa密码先在服务管理器停止Sql Server服务,然后打开命令行,进入 SQL Server安装目录,进入 ...

  6. 《JavaScript 闯关记》之变量和数据类型

    当程序需要将值保存起来以备将来使用时,便将其赋值给一个变量,值的类型称作数据类型. 变量 JavaScript 的变量是松散类型的,所谓松散类型就是可以用来保存任何类型的数据.换句话说,每个变量仅仅是 ...

  7. 在SQL中修改数据库名称

    假设SQL Server 2008中有个数据库test,现在要将其改名为zhy步骤:(1) 分离数据库:打开management studio,找到test数据库-->右键-->任务--& ...

  8. SQL随机查询,显示行号,查询数据段

    1.显示行号 如果数据没有删除的情况下主键与行号是一致的,但在删除某些数据,行号就与主键不一致了,这时需要查询行号就需要用新的方法,在SQL Server2005之前,需要使用临时表,但在SQL Se ...

  9. 异常 java.lang.NumberFormatException: For input string:

    今天在写项目时,将String类型转换为Integer类型爆出此异常,记录如下: 代码如下: 1 String a = "2222222222"; //10个2 Integer b ...

  10. vb的property 和event

    Event 语句 定义用户自定义的事件. 语法 [Public] Event procedurename [(arglist)] Event 语句包含下面部分: 部分 描述 Public 可选的.指定 ...