看似水但有技巧的题
protecteyesight
我向往天空的湛蓝和一望无际。保护视力,只为看到更远的天空。
展开
-
nefu 600 判断组合数的奇偶性
C(m,n)是一个组合数N!含有质因数2的个数,等于N减去N的二进制表示中1的个数。假设m!中2因子个数为a,n!中2因子个数为b,(m-n)!中2因子个数为c,则显然有a>=(b+c);并且当a==b+c时,一定为奇,否则为偶。#include using namespace std;int getn(int n){ int a=n,ans=0; while(a>原创 2017-03-20 20:13:31 · 316 阅读 · 0 评论 -
hdu 6077 Time To Get Up(简单模拟)
题意:把上面的矩阵里的时间输出思路:简单模拟一下代码:#include #include using namespace std;char c[7][21];int get(char c[7][4]){ bool a[7]; if(c[1][0]=='X'&&c[2][0]=='X')a[0]=true;else a[0]=false; if(原创 2017-08-16 17:14:34 · 251 阅读 · 0 评论 -
hdu 6033 Add More Zero(数的位数)
题意:求2的k次方的数的位数-1思路:数的位数 (int)log10(n)+1log10(2^k)=k*log10(2),取个int就行了#include #include #include #include #include #include using namespace std;int main(){ int a,ans,ca原创 2017-07-27 11:53:36 · 270 阅读 · 0 评论 -
CodeForces - 808B Average Sleep Time(水题+规律)
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!When Polycarp went to a doctor with his problem, the doctor asked h原创 2017-05-21 17:45:05 · 559 阅读 · 0 评论 -
HDU 6154 CaoHaha's staff(思维+找规律)
题目大意:输入一个数表示一个面积,然后输出最少画几划能够围成一个面积大于等于给定面积的多边形。画线的规则是假设有一个正方形,你可以连它的一条边,或是对角线,一个正方形的面积是1。分析:因为数据范围在int内,所以应该是推出一个公式什么的直接套。推公式:我们从面积推边数好像不太现实,因为有的固定边围成的最大面积是非整数的,也就是面积到边数的映射不是唯一的。但是,如果从边入原创 2017-08-21 14:14:28 · 259 阅读 · 0 评论 -
HDU 6130 Kolakoski(构造序列)
题意:构造出上面说的Kolakoski序列。介绍:Kolakoski序列是一个仅由1和2组成的无限数列,是一种通过“自描述”来定义的数列。他的前几项为1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1,2,1,1,2,1,2,2,1,1,…它的定义很简单,若把数列中相同的数定为一组,令a(1)=1,a(2)=2,则a(n)等于第n组数的长原创 2017-08-21 15:21:31 · 2211 阅读 · 0 评论 -
HDU 6124 Euler theorem(水+思维)
传送门题意:输入一个数a,求a%任意数有多少种可能。思路: 首先被题目骗了,欧拉定理???好像是没有太大联系。分析对于一个数,比如13和14那么,除数>13 13 12 11 10 9 8 7 6 5 4 3 2 1 余数:13 0 1 2 3 4 5 6 1 3 1 1 1 0 除数>14原创 2017-08-21 15:44:35 · 240 阅读 · 1 评论 -
数学知识技巧
取模:ACM竞赛中经常会见到取模的操作,取模的规则一般如下:对于加减乘运算,在运算之前取模和在运算之后取模的结果不变,因此可以在计算之前取模使得数据不会爆,注意中间如果是个多项式(有多步运算),那么每一次运算完都要取模,用来保证数据不会爆。但是对于除法,不能直接对除数取模,要乘以除数的逆元,这样才能保证数据正确。求逆元的方法有好多种,根据费马小定理的快速幂写法比较直观。(一个例子)原创 2017-09-07 20:33:32 · 218 阅读 · 0 评论 -
HDU 6048 Puzzle(逆序数+等差数列)
传送门题意: 给你一个N*M大小的矩阵,表示一个“拼图”模型,这个拼图有N*M-1个块,现在有1~N*M-1个编号,给你一个P,每次取第1个,第1+P个,第1+2*P个,第1+3*P个……依次从上到下,从左到右填入到模型中,问是否可以通过有限次的移动使得编号按照1~N*M-1的顺序排列好,输出YES和NO。思路:原排列的写出来之后写成一排,这个序列的逆序数为偶数即“YES”,否原创 2017-09-03 10:31:49 · 439 阅读 · 0 评论 -
HDU 6140 Hybrid Crystals(坑题+水题)
传送门题意:思路:题目比较坑,题中数据保证了这些数据能够组成最小值到最大值中的任意的数,因此,直接计算出这些数的最大最小值就行了。代码:#include using namespace std;int a[1005];char b[1005];int main(){ int n,k; int t; scanf("%d原创 2017-09-03 10:47:14 · 215 阅读 · 0 评论 -
HDU 3687 National Day Parade(暴力)
题意: 在一个n行m列大小的长方形的空地上,有n*n个人站在这里,保证每一行都有n个人,现在要求让他们站成一个正方形的队列,每个人只能在这一行移动,问最小移动的次数是多少。(人可以站在同一个点上)思路: 直接暴力,控制好变量就行了。#include using namespace std;struct aa{ int x,y,i;}a[3600原创 2017-10-28 10:40:38 · 224 阅读 · 0 评论 -
2017 秦皇岛CCPC M题 Safest Buildings(概率+思维+计算几何)
题意:题目说的是一个叫“吃鸡”的游戏。给出两个半径R,r,R表示第一次的大圈半径,r表示第二次的小圈半径。第一次大圈的圆心位于(0,0),第二次小圈的圆心未知,但在大圈内,给你一个n,然后给出n个屋子的位置,问这些屋子中,第二次在小圈的概率最大的屋子有几个,都是哪些。思路:首先分析到如果小圈是一个很小很小的圈,那么靠近原点的区域的这些点的概率是一样的,因为都可以使小圈360度绕着这原创 2017-10-29 19:19:40 · 2328 阅读 · 0 评论 -
hdu6069 Counting Divisors(质数分解+技巧)
d(n)里n的取值最大1e12,那么要判断它是不是素数只需计算到sqrt(n),所以打个1e6的素数表,如果它是个合数,就可以用打好的表里的素数进行分解,如果是个素数, 那么它对最后结果的贡献就是k+1。遍历和计算中的技巧:数组开到1e6,从l到r拿0到r-l对应。中间遍历时先遍历素数表,假设现在遍历到prime[i],先找到l~r第一个能整除prime[i]的数a[j],以此原创 2017-08-04 15:21:46 · 1280 阅读 · 2 评论 -
hdu 5047 java大数+思维
Think about a plane: ● One straight line can divide a plane into two regions. ● Two lines can divide a plane into at most four regions. ● Three lines can divide a plane into at most seven regi原创 2017-07-07 08:39:35 · 370 阅读 · 0 评论 -
hdu 4608 I - I-number()(高精度+暴力)
The I-number of x is defined to be an integer y, which satisfied the the conditions below: 1. y>x; 2. the sum of each digit of y(under base 10) is the multiple of 10; 3. among all integers that原创 2017-04-30 17:51:18 · 218 阅读 · 2 评论 -
HDU 5131 Song Jiang's rank list (确定排名经典问题)
《Shui Hu Zhuan》,also 《Water Margin》was written by Shi Nai'an -- an writer of Yuan and Ming dynasty. 《Shui Hu Zhuan》is one of the Four Great Classical Novels of Chinese literature. It tells a story abo原创 2017-07-31 14:02:30 · 257 阅读 · 0 评论 -
HDU - 5135(三角形存在判断)
Zu Chongzhi (429–500) was a prominent Chinese mathematician and astronomer during the Liu Song and Southern Qi Dynasties. Zu calculated the value ofπ to the precision of six decimal places and for a t原创 2017-07-31 13:46:41 · 841 阅读 · 2 评论 -
HDU 4920 坑爹的矩阵乘法
Given two matrices A and B of size n×n, find the product of them. bobo hates big integers. So you are only asked to find the result modulo 3.InputThe input consists of several tests. For each原创 2017-04-02 16:35:41 · 247 阅读 · 0 评论 -
一些基础的东西
本篇介绍:1.cmp函数的用法(sort的高级用法)2.C++常用的头文件3.打表算阶乘和斐波那契数列4.一些简单的函数及其调用5.字符串排序下面开始正文:1.cmp函数的用法(sort的高级用法)struct zf{ char a[21],b[21],c[21]; int abc;原创 2017-04-03 21:41:30 · 228 阅读 · 0 评论 -
Balls Rearrangement (找循环节)
Balls Rearrangement Bob has N balls and A boxes. He numbers the balls from 0 to N-1, and numbers the boxes from 0 to A-1. To find the balls easily, he puts the ball numbered x into the box numbe原创 2017-04-04 16:40:25 · 168 阅读 · 0 评论 -
由NEFU 519引发的思考(关于逆元)
兴安黑熊在高中学习数学时,曾经知道这样一个公式:f(n)=1^2+2^2+3^2+.......+n^2,这个公式是可以化简的,化简后的结果是啥它却忘记了,也许刚上大二的你能记得。现在的问题是想要计算f(n)对1007取余的值,你能帮帮他吗?Input输入数据有多组,每组一个数n. (1<=n <=1,000,000,000).原创 2017-05-24 14:30:10 · 269 阅读 · 0 评论 -
map容器的初体验
In college, a student may take several courses. for each course i, he earns a certain credit (c i), and a mark ranging from A to F, which is comparable to a score (s i), according to the following con原创 2017-04-16 15:11:16 · 190 阅读 · 0 评论 -
CodeForces - 807B T-Shirt Hunt(二分)
Not so long ago the Codecraft-17 contest was held on Codeforces. The top 25 participants, and additionally random 25 participants out of those who got into top 500, will receive a Codeforces T-shirt.原创 2017-05-21 17:54:31 · 281 阅读 · 0 评论 -
HDU 5976 贪心+逆元
F - Detachment HDU - 5976 In a highly developed alien society, the habitats are almost infinite dimensional space. In the history of this planet,there is an old puzzle. You have a line原创 2017-06-08 21:25:25 · 304 阅读 · 0 评论 -
简单易懂带注释学生管理系统
在大一下学期,我们的实习是做一个学生管理系统。系统啊……崩溃啊……不过还好我做出来了附上代码:这是主函数的:#include #include #include #include "paixu.h"int flag=0;int main(){ int nn; tishi(); stu *head=(stu*)malloc(sizeof(s原创 2016-12-21 12:07:46 · 732 阅读 · 3 评论 -
hdu 5112 A Curious Matt (结构体+cmp函数)
There is a curious man called Matt. One day, Matt's best friend Ted is wandering on the non-negative half of the number line. Matt finds it interesting to know the maximal speed Ted may reach. In原创 2017-06-26 14:14:30 · 274 阅读 · 0 评论 -
hdu 5122 K.Bro Sorting(思维+冒泡思想)
Matt’s friend K.Bro is an ACMer. Yesterday, K.Bro learnt an algorithm: Bubble sort. Bubble sort will compare each pair of adjacent items and swap them if they are in the wrong order. The process r原创 2017-06-26 14:23:09 · 275 阅读 · 0 评论 -
HDU 5512 Pagodas (水题+GCD )
nn pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 11 to nn. However, only two of them (labelled aa and bb, where 1≤a≠b≤n1≤a≠b≤n)原创 2017-06-15 14:54:25 · 353 阅读 · 0 评论 -
HDU 5128 The E-pang Palace (暴力+几何思维 详解)
E-pang Palace was built in Qin dynasty by Emperor Qin Shihuang in Xianyang, Shanxi Province. It was the largest palace ever built by human. It was so large and so magnificent that after many years of原创 2017-07-31 13:29:26 · 777 阅读 · 0 评论 -
HDU 5127 Dogs' Candies(瞎暴力)
Far far away, there live a lot of dogs in the forest. Unlike other dogs, those dogs love candies much more than bones. Every candy has two attributes: the sweetness degree p and the sourness degre原创 2017-07-31 12:29:24 · 341 阅读 · 0 评论 -
ICPC乌鲁木齐赛后感悟
最后一次比赛了,虽然打铁了,但是并不可惜,三人都尽了全力,坚持到了比赛的最后一刻,每个人都在为了这个团队付出,这才是比赛的意义所在。2017新疆乌鲁木齐icpc题目偏向数学,数学题好几道。B和G是两个签到题,看手速。D题正解是推出一个组合数的式子,我们用的是矩阵快速幂(全场过这题的估计没几个用这个的)。队友找的是三层的递推关系,我构造了6*6的矩阵,一切顺风顺水敲出了代码,但是前期一直原创 2017-12-04 21:23:40 · 343 阅读 · 4 评论