自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(53)
  • 收藏
  • 关注

原创 Fox And Two Dots

点击打开链接Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size n × m cells, like this:Each cell contains a dot that has some color. We w

2017-07-31 18:10:02 170

原创 Oil Deposits

点击打开链接Problem DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a t

2017-07-31 18:05:09 172

转载 memset函数使用详解

今天做题卡在MEMSET函数的使用上了,本来以为int a[100]; memset(a, MAX,sizeof(a));就是将a数组全部赋值为MAX,现在才知道他的填充是以字节为单位,一般用于对字符型变量的初值进行赋值.1。void *memset(void *s,int c,size_t n)总的作用:将已开辟内存空间 s 的首 n 个字节的值设为值 c。2

2017-07-31 11:35:41 276

转载 容斥原理 —— 求1~n有多少个数与k互质(二进制算法详细解释&模板)

void pr(int k) //求k的质因子 { num = 0; for (int i = 2 ; i * i <= k ; i++) { if (k % i == 0) { p[num++] = i; while (k % i == 0)

2017-07-30 21:08:26 408

原创 Co-prime

点击打开链接Problem DescriptionGiven a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N.Two integers are said to be co-

2017-07-30 20:42:55 144

原创 Halloween treats

例题2:任取5个整数,必然能够从中选出三个,使它们的和能够被3整除.证明:任意给一个整数,它被3除,余数可能为0,1,2,我们把被3除余数为0,1,2的整数各归入类r0,r1,r2.至少有一类包含所给5个数中的至少两个.因此可能出现两种情况:1°.某一类至少包含三个数;2°.某两类各含两个数,第三类包含一个数.若是第一种情况,就在至少包含三个数的那一类中任取三数,其和一定能被3整除

2017-07-30 15:52:33 229

转载 欧拉函数

一欧拉函数(Euler's totient function) 欧拉函数的定义:    在数论中,对于正整数N,少于或等于N ([1,N]),且与N互质的正整数(包括1)的个数,记作φ(n)。     φ函数的值:    φ(x)=x(1-1/p(1))(1-1/p(2))(1-1/p(3))(1-1/p(4))…..(1-1/p(n)) 其中p(1),p(

2017-07-30 12:21:10 269

转载 Divisibility

点击打开链接Find the number of k-divisible numbers on the segment [a, b]. In other words you need to find the number of such integer values x that a ≤ x ≤ b and x is divisible by k.InputTh

2017-07-29 11:54:45 182

原创 Uncowed Forces

点击打开链接Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 25

2017-07-29 10:54:22 193

原创 I - Restaurant

点击打开链接A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the star

2017-07-29 10:06:44 145

原创 H - Bulbs

点击打开链接Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can pre

2017-07-29 10:03:16 252

原创 G - New Year and Days

点击打开链接Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015.Limak is a little polar bear. He enjoyed this year a lot.

2017-07-29 10:01:36 212

原创 F - Pasha and Stick

点击打开链接Pasha has a wooden stick of some positive integer length n. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and

2017-07-29 09:54:29 241

原创 C - Patrick and Shopping

点击打开链接今天 Patrick 等待着他的朋友 Spongebob 来他家玩。为了迎接 Spongebob,Patrick 需要去他家附近的两家商店  买一些吃的。他家离第一家商店有d1米远,离第二家商店有d2米远。还有,两家商店之间的距离是d3,帮Patrick计算去两家商店然后回家的最短距离。Patrick 永远从他家出发,他不介意重复经过同一个地点或者同一条路,

2017-07-29 09:50:39 246

原创 B - Tricky Sum

点击打开链接In this problem you are to calculate the sum of all integers from 1 to n, but you should take all powers of two with minus in the sum.For example, for n = 4 the sum is equal to

2017-07-29 09:45:02 185

原创 I - Rightmost Digit

点击打开链接Given a positive integer N, you should output the most right digit of N^N. InputThe input contains several test cases. The first line of the input is a single integer T which i

2017-07-28 10:28:17 154

原创 F - 分拆素数和

点击打开链接把一个偶数拆成两个不同素数的和,有几种拆法呢?Input输入包含一些正的偶数,其值不会超过10000,个数不会超过500,若遇0,则结束。Output对应每个偶数,输出其拆成不同素数的个数,每个结果占一行。Sample Input30260Sample Output32分析:先用素数打表法把素数找出来,之后两

2017-07-28 10:14:59 169

原创 E - 素数判定

点击打开链接对于表达式n^2+n+41,当n在(x,y)范围内取整数值时(包括x,y)(-39Input输入数据有多组,每组占一行,由两个整数x,y组成,当x=0,y=0时,表示输入结束,该行不做处理。Output对于每个给定范围内的取值,如果表达式的值都为素数,则输出"OK",否则请输出“Sorry”,每组输出占一行。 Sample Input0 1

2017-07-28 10:07:59 207

原创 D - 最小公倍数

点击打开链接给定两个正整数,计算这两个数的最小公倍数。Input输入包含多组测试数据,每组只有一行,包括两个不大于1000的正整数.Output对于每个测试用例,给出这两个数的最小公倍数,每个实例输出一行。 Sample Input10 14Sample Output70

2017-07-28 10:03:54 126

原创 C - 又见GCD

点击打开链接有三个正整数a,b,c(0Input第一行输入一个n,表示有n组测试数据,接下来的n行,每行输入两个正整数a,b。 Output输出对应的c,每组测试数据占一行。 Sample Input26 212 4Sample Output48代码:#includeint gcd(int a

2017-07-28 10:01:33 177

原创 B - Cake

点击打开链接一次生日Party可能有p人或者q人参加,现准备有一个大蛋糕.问最少要将蛋糕切成多少块(每块大小不一定相等),才能使p人或者q人出席的任何一种情况,都能平均将蛋糕分食. Input每行有两个数p和q. Output输出最少要将蛋糕切成多少块. Sample Input2 3Sample Output4

2017-07-28 09:52:02 159

原创 A - Wolf and Rabbit

点击打开链接There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must hide in one of the holes. A wolf searches the rabbit in anticlockwise order. The fi

2017-07-28 09:36:46 196

原创 会场安排问题

点击打开链接描述学校的小礼堂每天都会有许多活动,有时间这些活动的计划时间会发生冲突,需要选择出一些活动进行举办。小刘的工作就是安排学校小礼堂的活动,每个时间最多安排一个活动。现在小刘有一些活动计划的时间表,他想尽可能的安排更多的活动,请问他该如何安排。输入第一行是一个整型数m(m每组测试数据的第一行是一个整数n(1随后的n行,每行

2017-07-27 22:20:56 154

原创 喷水装置(一)

点击打开链接描述现有一块草坪,长为20米,宽为2米,要在横中心线上放置半径为Ri的喷水装置,每个喷水装置的效果都会让以它为中心的半径为实数Ri(0<Ri<15)的圆被湿润,这有充足的喷水装置i(1<i<600)个,并且一定能把草坪全部湿润,你要做的是:选择尽量少的喷水装置,把整个草坪的全部湿润。输入第一行m表示有m组测试数据每一组测试数据的第一行有一

2017-07-27 22:14:14 126

原创 阶乘之和

点击打开链接描述给你一个非负数整数n,判断n是不是一些数(这些数不允许重复使用,且为正数)的阶乘之和,如9=1!+2!+3!,如果是,则输出Yes,否则输出No;输入第一行有一个整数0每组测试数据有一个正整数n输出如果符合条件,输出Yes,否则输出No;样例输入2910样例输出YesNo分析:其实10!>1000000

2017-07-27 21:57:31 185

原创 C - Trailing Zeroes (III)

点击打开链接You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 1*2*...*N. For example, 5! = 120, 120 contains one

2017-07-27 21:50:47 197

原创 B - Pie

点击打开链接My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my pa

2017-07-27 21:38:25 140

转载 char,short ,int ,long,long long,unsigned long long数据范围

速查表:char -128 ~ +127 (1 Byte)short -32767 ~ + 32768 (2 Bytes)unsigned short 0 ~ 65535 (2 Bytes)int -2147483648 ~ +2147483647 (4 Bytes)unsigned int 0 ~ 4294967295 (4 Bytes)long == intlo

2017-07-27 19:40:45 348

转载 计算任意数阶乘n!末尾所含0的个数

1. 问题描述    给定参数n(n为正整数),请计算n的阶乘n!末尾所含有“0”的个数。    例如,5!=120,其末尾所含有的“0”的个数为1;10!= 3628800,其末尾所含有的“0”的个数为2;20!= 2432902008176640000,其末尾所含有的“0”的个数为4。       2. 计算公式    这里先给出其计算公式,后面给出推导过程。   

2017-07-27 17:55:49 483

转载 二分法查找C语言实现

二分法查找:a是查找的数组,二分法查找的前提条件是a数据的排序是有序的。key是待查找的变量,n是数组a的长度。int binary( int *a, int key, int n ){    int left = 0, right = n - 1, mid = 0;    mid = ( left + right ) / 2;    while( left

2017-07-27 09:16:31 1235

原创 题目1172:哈夫曼树

点击打开链接题目描述:哈夫曼树,第一行输入一个数n,表示叶结点的个数。需要用这些叶结点生成哈夫曼树,根据哈夫曼树的概念,这些结点有权值,即weight,题目需要输出所有结点的值与权值的乘积之和。输入:输入有多组数据。每组第一行输入一个数n,接着输入n个叶节点(叶节点权值不超过100,2输出:输出权值。

2017-07-26 19:26:50 209

原创 F - 分拆素数和 (素数打表)

点击打开链接素数也是质数,它只有1和本身两个约数。素数打表:[cpp] view plain copy#include  int n,i,j,a[1000001],p[100000],t=0;  void main()  {      scanf("%d",&n);      a[1]=0;

2017-07-26 19:15:03 172

转载 大数阶乘算法

首先定义一个足够长的数组。拿10000的阶乘为例,最后的结果长度是35660位,所以我们定义一个40000个成员的数组就可以了。int result[40000];其核心思想就是把计算结果每一位上的数字保存到一个数组成员中,例如:把124保存至数组中,保存结果应该是result[0] 4result[1] 2result[2] 1这样肯定是没有问题的,一个int型数

2017-07-26 16:14:48 662

转载 priority_queue<int,vector<int>,greater<int>>优先队列 按照由小到大顺序

C++优先队列的基本使用方法 #include#include#includeusing namespace std;struct node{    friend bool operator    {        return n1.priority "为从小打到排列    }    int priority;    int val

2017-07-26 14:43:03 4528

原创 K - 今年暑假不AC

点击打开链接“今年暑假不AC?” “是的。” “那你干什么呢?” “看世界杯呀,笨蛋!” “@#$%^&*%...” 确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。 作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些其它的节目,比如新闻联播(永远不要忘记关心国家大事)、非常6

2017-07-24 17:20:17 323

原创 G - Bear and Three Balls

点击打开链接Limak is a little polar bear. He has n balls, the i-th ball has size ti.Limak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak

2017-07-24 12:17:46 151

原创 F - What Is Your Grade?

点击打开链接“Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you

2017-07-24 12:11:14 230

原创 E - 稳定排序

点击打开链接大家都知道,快速排序是不稳定的排序方法。 如果对于数组中出现的任意aii,ajj(iii==ajj,在进行排序以后aii一定出现在ajj之前,则认为该排序是稳定的。 某高校招生办得到一份成绩列表,上面记录了考生名字和考生成绩。并且对其使用了某排序算法按成绩进行递减排序。现在请你判断一下该排序算法是否正确,如果正确的话,则判断该排序算法是否为稳定的。 

2017-07-24 12:01:26 267

原创 D - 统计同成绩学生人数

点击打开链接读入N名学生的成绩,将获得某一给定分数的学生人数输出。 Input测试输入包含若干测试用例,每个测试用例的格式为 第1行:N 第2行:N名学生的成绩,相邻两数字用一个空格间隔。 第3行:给定分数 当读到N=0时输入结束。其中N不超过1000,成绩分数为(包含)0到100之间的一个整数。 Output对每个测试用例,将获

2017-07-24 11:58:35 148

原创 C - 前m大的数

点击打开链接还记得Gardon给小希布置的那个作业么?(上次比赛的1005)其实小希已经找回了原来的那张数表,现在她想确认一下她的答案是否正确,但是整个的答案是很庞大的表,小希只想让你把答案中最大的M个数告诉她就可以了。 给定一个包含N(NInput输入可能包含多组数据,其中每组数据包括两行: 第一行两个数N和M, 第二行N个数,表示该序列。 

2017-07-24 11:55:40 205

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除