对于这题笔者认为可以用数学排列来算,但是由于笔者很懒所以抄了一段大神的代码来交个大家了,

这位大神的基本想法就是通过记录各类书的数量,再暴力破解;

下面贴出这位大神的代码吧:

 #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std; int h[];
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
{
int x;scanf("%d",&x);
h[x]++;
}
long long ans = ;
for(int i=;i<=m;i++)
for(int j=i+;j<=m;j++)
ans+=h[i]*h[j];
cout<<ans<<endl;
}

CodeForce---Educational Codeforces Round 3 The best Gift 解题报告的更多相关文章

  1. Codeforce |Educational Codeforces Round 77 (Rated for Div. 2) B. Obtain Two Zeroes

    B. Obtain Two Zeroes time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. codeforces 505A. Mr. Kitayuta's Gift 解题报告

    题目链接:http://codeforces.com/problemset/problem/505/A 题目意思:给出一个长度不大于10的小写英文字符串 s,问是否能通过在字符串的某个位置插入一个字母 ...

  3. Codeforces Round #232 (Div. 1) A 解题报告

    A. On Number of Decompositions into Multipliers 题目连接:http://codeforces.com/contest/396/problem/A 大意: ...

  4. codeforces A. Kitahara Haruki's Gift 解题报告

    题目链接:http://codeforces.com/problemset/problem/433/A 题目意思:给定 n 个只由100和200组成的数,问能不能分成均等的两份. 题目其实不难,要考虑 ...

  5. [Codeforces Round #194 (Div. 2)] Secret 解题报告 (数学)

    题目链接:http://codeforces.com/problemset/problem/334/C 题目: 题目大意: 给定数字n,要求构建一个数列使得数列的每一个元素的值都是3的次方,数列之和S ...

  6. Codeforces Round 319 # div.1 & 2 解题报告

    Div. 2 Multiplication Table (577A) 题意: 给定n行n列的方阵,第i行第j列的数就是i*j,问有多少个格子上的数恰为x. 1<=n<=10^5, 1< ...

  7. Codeforces Round #231 (Div2) 迟到的解题报告

    题目A: 给一个火柴等式,可以从左边移动一根到右边,也可以从右边移到左边,但是不能移动“+”,”=“的火柴, 而且加法里面的数都要大于0(很重要的条件),基本上注意到这点的都过了,没注意的都被HACK ...

  8. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...

  9. [Educational Codeforces Round 16]E. Generate a String

    [Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...

随机推荐

  1. 1195: [HNOI2006]最短母串 - BZOJ

    Description 给定n个字符串(S1,S2,„,Sn),要求找到一个最短的字符串T,使得这n个字符串(S1,S2,„,Sn)都是T的子串.Input 第一行是一个正整数n(n<=12), ...

  2. uc/os 任务删除

    问题描述:     uc/os 任务删除 问题解决: uc/os任务删除流程图 具体代码 注:     如上是关中断,以及取消优先级对应的就绪标志 关中断代码为: 取消就绪标志,实际上是将就绪表中指定 ...

  3. IOS xib生成界面和代码生成界面两种方式混合

    应用程序代理类 WKAppDelegate.m // // WKAppDelegate.m // HelloWorld // // Created by easy5 on 13-9-18. // Co ...

  4. 《Introduction to Tornado》中文翻译计划——第五章:异步Web服务

    http://www.pythoner.com/294.html 本文为<Introduction to Tornado>中文翻译,将在https://github.com/alioth3 ...

  5. MySql不同版本安装

    1.win7 64位下如何安装配置mysql-5.7.4-m14-winx64  1. mysql-5.7.4-m14-winx64.zip下载 2.解压到D:/mysql.(路径自己指定) 3.在D ...

  6. SPRING IN ACTION 第4版笔记-第九章Securing web applications-001-SpringSecurity简介(DelegatingFilterProxy、AbstractSecurityWebApplicationInitializer、WebSecurityConfigurerAdapter、@EnableWebSecurity、@EnableWebMvcS)

    一.SpringSecurity的模块 At the least, you’ll want to include the Core and Configuration modules in your ...

  7. c++ const 关键字 学习笔记

    const简单介绍: 1不再使用c中的#define,c++默认不给const定义的变量分配内存,所以它默认的是仅本文件可以看到该变量(即internal linkage), const int bu ...

  8. 无效的 URI: 未能分析证书颁发机构/主机

    出 现该错误的原因是URL中少了一个斜杠,正常的URL是“http:”后边有两个斜杠,而我在修改配置文件中的URL的IP地址部分时,不小心删掉了一个 斜杠,例如:http:/blog.csdn.net ...

  9. C#获取本地打印机列表,并将指定打印机设置为默认打印机

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...

  10. [转] android自动化测试之MonkeyRunner使用实例(三)

    一.使用CMD命令打开模拟器 运行monkeyrunner之前必须先运行相应的模拟器或连上设备,不然monkeyrunner无法连接设备. 1.1  用Elipse打开Android模拟器或在CMD中 ...