- 博客(49)
- 收藏
- 关注
原创 欧拉函数
#include <iostream>#include <cstdio>using namespace std;const int Max = 100000;int euler[Max];void Init(){ euler[1] = 1; for(int i = 2; i < Max; i++) { euler[i]=i; ...
2018-08-31 18:56:55 309
原创 矩阵翻转(数组模拟)
问题晓萌最近在做一个翻转图片的应用,你可能也知道,图片其实是由一个个的点组成的。于是,晓萌想先做一个可以翻转矩阵的程序,来解决他问题的核心部分。输入格式输入第一行包括由空格分开的整数 M,N,T(0 < N,M < 200)M,N,T(0<N,M<200),TT 的值为 00 或 11。其中 MM 和 NN 分别表示待处理矩阵的行数与列数,TT 为 00 时表示...
2018-08-29 18:53:34 758
原创 求2的n次方
方法一这样最多可以计算出2的1000次方左右。#include <iostream>#include <cmath>#include <iomanip>using namespace std;int main() { int n; while(cin>>n) { cout<<fixed&l...
2018-08-26 16:51:10 3008
原创 HDU 6440 2018中国大学生程序设计网络选拔赛
Problem DescriptionFreshmen frequently make an error in computing the power of a sum of real numbers, which usually origins from an incorrect equation (m+n)p=mp+np, where m,n,p are real numbers. Let...
2018-08-26 13:41:42 360
原创 勾股数规律(任意三个数能够满足勾股定理需要满足的条件)
一、勾股数形如 一类的数称为勾股数(a,b,c为正整数)。二、一些性质1.直角三角形的两条直角边和斜边满足勾股数定理。2. . .3.当a为奇数时,,则 , . 4.当a为偶数时,, 则 , . 三、费马大定理, 当n>2时,方程没有正解。...
2018-08-26 13:21:47 13505
原创 HDU 1372 & POJ 2243 Knight Moves(广度优先搜索)
Problem DescriptionA friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n ...
2018-08-24 17:49:23 455
原创 HDU 6281 sorting (湘潭邀请赛F题)
Problem DescriptionBobo has n tuples (a1,b1,c1),(a2,b2,c2),…,(an,bn,cn).He would like to find the lexicographically smallest permutation p1,p2,…,pn of 1,2,…,n such that for i∈{2,3,…,n} it holds tha...
2018-08-24 17:00:12 814
原创 HDU 3037 Saving Beans (Lucas定理求大数组合数)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3037#include <iostream>#include <cstdio>using namespace std;typedef long long ll;const int N = 150000;ll n, m, p;ll fac[N];void in...
2018-08-21 11:54:21 347 2
原创 HDU 6362 oval-and-rectangle(圆锥曲线+积分+函数期望)
Problem Description Patrick Star find an oval. The half of longer axes is on the x-axis with length a . The half of shorter axes is on the y-axis with length b . Patrick Star plan to ...
2018-08-21 11:50:46 329
原创 Educational Codeforces Round 49 (Rated for Div. 2) problem A Palindromic Twist
Problem DescriptionYou are given a string ss consisting of nn lowercase Latin letters. nn is even.For each position ii (1≤i≤n1≤i≤n) in string ss you are required to change the letter on this posit...
2018-08-19 10:09:47 344
原创 牛客小白月赛6 H挖沟(并查集)
题目链接:https://www.nowcoder.com/acm/contest/136/H#include<bits/stdc++.h>using namespace std;const int N=5e5+5;int n,m,tot;int p[N];struct node{ int u,v,w;}a[N];bool cmp(node a,node b...
2018-08-19 10:02:48 316
原创 牛客小白月赛6 F发电(线段树)
题目链接:https://www.nowcoder.com/acm/contest/136/F线段树求区间的积。注意:点更新(除以一个数)的时候一定要乘以它的逆元否则一直WA。不要问我怎么知道的,,,#include <cstdio>#include <iostream>#define lson l ,mid ,t << 1#define rso...
2018-08-19 09:59:58 318
原创 牛客小白月赛6 D字符串丝带
题目链接:https://www.nowcoder.com/acm/contest/136/D#include <iostream>#include <cstring>#include <cstdio>#include <map>using namespace std;map<char,int>mp;int ans[10...
2018-08-19 09:56:12 345
原创 牛客小白月赛6 C 题 桃花
题目链接:https://www.nowcoder.com/acm/contest/136/C#include <iostream>#include <vector>#include <algorithm>using namespace std;int maxDistance = 0;vector<vector<int> >...
2018-08-18 22:32:46 314
原创 牛客小白月赛6 B题鹏
题目链接:https://www.nowcoder.com/acm/contest/136/B题目描述 化而为鸟,其名为鹏。鹏之背,不知其几千里也。 ——《庄子·逍遥游》 HtBest的小鲲长大变成了大鹏,大鹏在天际翱翔,看到了一片绵延的山脉,每座山都有自己的高度,大鹏想穿过这片山脉。由于他只...
2018-08-18 22:31:01 361
原创 HDU 1071 The area (数学求定积分)
Problem Description Ignatius bought a land last week, but he didn't know the area of the land because the land is enclosed by a parabola and a straight line. The picture below shows the area. N...
2018-08-15 10:53:30 451
原创 矩阵的和(规律)
Problem Description我们定义如下矩阵: 1/1 1/2 1/3 1/2 1/1 1/2 1/3 1/2 1/1 矩阵对角线上的元素始终是1/1,对角线两边分数的分母逐个递增。 请求出这个矩阵的总和。 Input每行给定整数N (N<50000),表示矩阵为 N*N.当N为0时,输入结束。Output输出答案,保留2位小数。Sample In...
2018-08-15 10:47:09 2233
原创 HDU 6112 今夕何夕(模拟)
Problem Description 今天是2017年8月6日,农历闰六月十五。 小度独自凭栏,望着一轮圆月,发出了“今夕何夕,见此良人”的寂寞感慨。 为了排遣郁结,它决定思考一个数学问题:接下来最近的哪一年里的同一个日子,和今天的星期数一样?比如今天是8月6日,星期日。下一个也是星期日的8月6日发生在2023年。 小贴士:在公历中,能被4整除但不能被100整除...
2018-08-15 10:40:10 490
原创 ICPC2017南宁邀请赛1001&&HDU6182 A Math Problem
Problem Description You are given a positive integer n, please count how many positive integers k satisfy kk≤n . Input There are no more than 50 test cases. Each case only contains ...
2018-08-15 10:35:01 347
原创 C语言字符检测函数:isalnum、isalpha、isascii、iscntrl、isdigit、isgraph、islower、isspace、ispunct、isupper
头文件:#include<ctype.h>(1)isalnum(c)检查参数 c 是否为英文字母或阿拉伯数字, 在标准c 中相当于使用"isalpha(c) || isdigit(c)"做测试.(2)isalpha(c)检查参数 c 是否为英文字母, 在标准c 中相当于使用"isupper(c)||islower(c)"做测试.(3)issupper(c)检查参...
2018-08-14 15:16:18 696
原创 strchr()函数与strrchr()函数的实现
char *strchr(const char *s, int c) 功能: 查找字符串s中首次出现c字符的位置说明: 返回首次出现c的位置的指针,返回的地址是被查找的字符串指针开始的第一个与c相同字符的指针,若s中不存在c则返回NULL。。。。返回值: 成功返回要查找的字符第一次出现的位置,否则返回NULL。。。。 char *strrchr(const char *s, in...
2018-08-13 21:54:08 6457
原创 sprintf函数的作用及用法
头文件:stdio.h函数功能:格式化字符串,将格式化的数据写入字符串中。函数原型:int sprintf(char *buffer, const char *format, [argument]...)参数:(1)buffer:是char类型的指针,指向写入的字符串指针;(2)format:格式化字符串,即在程序中想要的格式;(3)argument:可选参数,可以为任意类...
2018-08-13 21:40:33 5779
原创 排列(思路)
题目:用1,2,3……9组成3个三位数abc,def和ghi,每个数字恰好使用一次,要求abc:def:ghi = 1:2:3。输出所有解。提示:不必太动脑筋。分析:确实是不要想太多,3位数所以abc的范围只能是100-333,所以#include <stdio.h>int main() { int x, y, z, a[10] = {0}; for(x = 100; ...
2018-08-13 20:41:44 296
原创 51Nod 1004 n^n的末位数字(快速幂+模运算)
Problem给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字。Input一个数N(1 <= N <= 10^9)Output输出N^N的末位数字Input示例13Output示例3#include <iostream>#include <cstdio>using namespace std;...
2018-08-12 17:18:31 293
原创 51Nod 1003 阶乘后面0的数量(思路+递归)
题目大意:求n的阶乘末尾有多少个0.#include <iostream>#include <vector>#include <cstdio>using namespace std;int f(int n) { if(n < 5) { return 0; } return n/5 + f(n/5);}...
2018-08-12 17:13:30 228
原创 51Nod 1001 数组中和等于K的数对(二分)
Problem:给出一个整数K和一个无序数组A,A的元素为N个互不相同的整数,找出数组A中所有和等于K的数对。例如K = 8,数组A:{-1,6,5,3,4,2,9,0,8},所有和等于8的数对包括(-1,9),(0,8),(2,6),(3,5)。Input第1行:用空格隔开的2个数,K N,N为A数组的长度。(2 <= N <= 50000,-10^9 <= K ...
2018-08-12 16:41:30 240
原创 Codeforces Round #503 Div 2 B. Badge
In Summer Informatics School, if a student doesn't behave well, teachers make a hole in his badge. And today one of the teachers caught a group of nn students doing yet another trick.Let's assu...
2018-08-12 10:09:04 447
原创 Codeforces Round #503 Div 2 A. New Building for SIS
Problem DescriptionYou are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locat...
2018-08-12 10:04:31 375
原创 求大组合数(卢卡斯定理) 牛客2018暑假多校第八场G题
题目描述Niuniu likes mathematics. He also likes drawing pictures. One day, he was trying to draw a regular polygon with n vertices. He connected every pair of the vertices by a straight line as well. He...
2018-08-11 16:48:41 492
原创 二分算法
Problem躺在床上不久我便心安理得的睡着了, 我梦见老板给我发了K个红包于是我便开开心心地去超市买吃的. 超市一共有ABC三个货架, 每个货架上都有若干种商品(每种有无限多个), 比如A货架上的第i种商品的价格是Ai元.对于每个红包, 我想要从三个货架上各拿一个商品, 把红包里的钱恰好花光, 这可能吗?Input每个输入包含多组样例. 每组样例的第一行有三个整数L, N, M...
2018-08-11 10:30:24 364
原创 HDU 1233 还是畅通工程(最小生成树 Prime&Kruskal)
Problem Description 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。 Input 测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( < ...
2018-08-10 20:24:46 281 1
原创 HDU 1232 畅通工程(并查集模板题)
Problem Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input 测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( &...
2018-08-10 19:24:09 192
原创 HDU 5144 NPY and shot(物理+二分)
Problem Description NPY is going to have a PE test.One of the test subjects is throwing the shot.The height of NPY is H meters.He can throw the shot at the speed of v0 m/s and at the height of...
2018-08-10 16:36:07 236
原创 POJ 2976 Dropping tests(01分数规划)
DescriptionIn a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be.Given your test scores and a positive integer k, d...
2018-08-10 16:27:20 153
原创 POJ 1064 Cable master(二分法)
DescriptionInhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was ...
2018-08-10 11:59:02 451 1
原创 HDU 1757 A Simple Math Problem(矩阵快速幂)
Problem Description Lele now is thinking about a simple function f(x). If x < 10 f(x) = x. If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10); And ai(...
2018-08-10 11:43:28 240
原创 POJ 2406 Power Strings
DescriptionGiven two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiat...
2018-08-10 11:29:38 126
原创 HDU 1251 统计难题
Problem DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连串的提问,每行...
2018-08-08 21:42:20 233
原创 HDU 6208 The Dominator of Strings
Problem DescriptionHere you have a set of strings. A dominator is a string of the set dominating all strings else. The string S is dominated by T if S is a substring of T.InputThe input contains...
2018-08-06 11:39:22 132
原创 HDU 1248 寒冰王座(完全背包)
Problem Description不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前.死亡骑士:"我要买道具!"地精商人:"我们这里有三种道具,血瓶150块一个,魔法药200块一个,无敌药水350块一个."死亡骑士:"好的,给我一个血瓶."说完他掏出那张N元的大钞递给地精商人.地...
2018-08-06 11:19:17 154
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人