CodeForce---Educational Codeforces Round 3 The best Gift 解题报告
对于这题笔者认为可以用数学排列来算,但是由于笔者很懒所以抄了一段大神的代码来交个大家了,
这位大神的基本想法就是通过记录各类书的数量,再暴力破解;
下面贴出这位大神的代码吧:
#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 解题报告的更多相关文章
- 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 ...
- codeforces 505A. Mr. Kitayuta's Gift 解题报告
题目链接:http://codeforces.com/problemset/problem/505/A 题目意思:给出一个长度不大于10的小写英文字符串 s,问是否能通过在字符串的某个位置插入一个字母 ...
- Codeforces Round #232 (Div. 1) A 解题报告
A. On Number of Decompositions into Multipliers 题目连接:http://codeforces.com/contest/396/problem/A 大意: ...
- codeforces A. Kitahara Haruki's Gift 解题报告
题目链接:http://codeforces.com/problemset/problem/433/A 题目意思:给定 n 个只由100和200组成的数,问能不能分成均等的两份. 题目其实不难,要考虑 ...
- [Codeforces Round #194 (Div. 2)] Secret 解题报告 (数学)
题目链接:http://codeforces.com/problemset/problem/334/C 题目: 题目大意: 给定数字n,要求构建一个数列使得数列的每一个元素的值都是3的次方,数列之和S ...
- Codeforces Round 319 # div.1 & 2 解题报告
Div. 2 Multiplication Table (577A) 题意: 给定n行n列的方阵,第i行第j列的数就是i*j,问有多少个格子上的数恰为x. 1<=n<=10^5, 1< ...
- Codeforces Round #231 (Div2) 迟到的解题报告
题目A: 给一个火柴等式,可以从左边移动一根到右边,也可以从右边移到左边,但是不能移动“+”,”=“的火柴, 而且加法里面的数都要大于0(很重要的条件),基本上注意到这点的都过了,没注意的都被HACK ...
- 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 ...
- [Educational Codeforces Round 16]E. Generate a String
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...
随机推荐
- 实用程序Commer的开发——U盘内容可选同步至FTP服务器
需求分析:需要在软件运行后将插入的U盘里面的文件Copy至本机上,然后可选的上传一部分至FTP服务器上. 系统设计:基于MFC的基本对话框程序:主要模块有检测U盘插入并复制文件以及上传到网络.通过对U ...
- jquery bind()方法与live()方法的区别
jquery bind() 方法和 live() 方法都可以绑定元素事件. <!DOCTYPE html> <html> <head> <meta chars ...
- google protobuf 使用示例
定义.proto接口文件 package tutorial; message Person { required ; required int32 id = ; //unique ID number ...
- Matlab中添加搜索目录
一.问题来源 来自于一份大规模hash图像检索代码. 二.问题解析 2.1 添加目录 addpath('./utils/'); 2.2 添加目录及其子目录 addpath(genpath('./uti ...
- where, group by, having
where vs having 当一个sql语句中存在where子句,会先执行where,然后执行group by,然后执行having. 一般来说,only use 'having' when yo ...
- 软件调试之INT 3讲解
第4章断点和单步执行 断点和单步执行是两个经常使用的调试功能,也是调试器的核心功能.本章我们将介绍IA-32 CPU是如何支持断点和单步执行功能的.前两节将分别介绍软件断点和硬件断点,第4.3节介绍用 ...
- uva 10056
概率 Q += p*pow(1-p, i*n+k-1) i = 0,1,2,3...... #include <cstdio> #include <cmath> int mai ...
- HDU4602+推导公式
手动列出前5项 可发现规律 /* 推导公式 a[n] = 2^(n-1) + (n-2)*2^(n-3) */ #include<stdio.h> #include<math.h&g ...
- nyist 510昂贵的聘礼
/* 好好的图论题啊,最短路的应用,dijkstra算法 */ #include <iostream> using namespace std; const int INF=100000; ...
- java学习面向对象之匿名内部类
之前我们提到“匿名”这个字眼的时候,是在学习new对象的时候,创建匿名对象的时候用到的,之所以说是匿名,是因为直接创建对象,而没有把这个对象赋值给某个值,才称之为匿名. 匿名对象回顾: class N ...