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. devStack

    1,devstack shell 脚本开源官网 http://devstack.org/ 脚本功能快速搭建 OpenStack 的运行和开发环境 [Note tips by Ruiy devstack ...

  2. 【转】android camera(一):camera模组CMM介绍

    关键词:android  camera CMM 模组 camera参数平台信息:内核:linux系统:android 平台:S5PV310(samsung exynos 4210)  作者:xubin ...

  3. .net项目中上传大图片失败

    .net项目中有时用户提出要上传大图片,一张图片有可能十几兆,本来用的第三方的上传控件,有限制图片上传大小的设置,以前设置的是2M.按照用户的要求,以为直接将限制图片上传大小的设置改下就可以了,但是当 ...

  4. UML图总结

    UML叙述 UML文档仅仅是设计与开发人员采用UML语言进行系统分析与设计的结果,并没有给出如何进行开发和采用何种开发流程,同样也不指导如何进行面向对象设计. UML文档描述了面向对象分析与设计的结果 ...

  5. Trie树|字典树(字符串排序)

    有时,我们会碰到对字符串的排序,若采用一些经典的排序算法,则时间复杂度一般为O(n*lgn),但若采用Trie树,则时间复杂度仅为O(n). Trie树又名字典树,从字面意思即可理解,这种树的结构像英 ...

  6. 【常用小命令】解决windows下有些文件文件名识别不了导致删除不了的问题

    在百度上找的解决方案哈,只为自己存档一份. 因为发现现在从csdn上下载的文件都是“.pdf_”格式,下载2个文件,将一个文件格式改成 “.pdf”,另一个文件就扔回不了回收站了, 所以没有办法就找各 ...

  7. 基于.Net的单点登录(SSO)解决方案

    前些天一位朋友要我帮忙做一单点登录,其实这个概念早已耳熟能详,但实际应用很少,难得最近轻闲,于是决定通过本文来详细描述一个SSO解决方案,希望对大家有所帮助.SSO的解决方案很多,但搜索结果令人大失所 ...

  8. iOS 使用NJKWebViewProgress做webview进度条

    NJKWebViewProgress地址:https://github.com/ninjinkun/NJKWebViewProgress 导入头文件 #import "NJKWebViewP ...

  9. Oracle查询指定某一天数据,日期匹配

    在做一个功能的时候,需要在oracle数据库中查询指定某一天的数据. 如果是简单的当前日期前后几天,也好办 AND TO_CHAR(Rct.Creation_Date, 'YYYY-MM-DD')=t ...

  10. (转载)C++之tinyXML使用

     tinyXML一款很优秀的操作C++类库,文件不大,但方法很丰富,和apache的Dom4j可以披靡啊!习惯了使用java类库的我看到这么丰富的c++类库,很高兴!它使用很简单,只需要拷贝几个文件到 ...