数学
剑断青丝i
世界上唯一可以阻止你前进的就是懒惰
展开
-
分数化小数(c语言)
输入正整数a,b,c,输出a/b的小数形式,精确到小数点后c位。a,b≤10 6 ,c≤100。输入包含多组数据, 结束标记为a=b=c=0。样例输入:1 6 40 0 0样例输出:Case 1: 0.1667题意分析:以前我们做过的题都是提上要求你保留几位小数,给出确定的值,而现在要求的是保留小数点后n位。#include<stdio.h>int main(){ ...原创 2019-11-05 20:16:50 · 2326 阅读 · 3 评论 -
第十届蓝桥杯C/C++ B组——等差数列
时间限制: 1.0s 内存限制: 256.0MB 本题总分:20 分【题目描述】数学老师给小明出了一道等差数列求和的题目。但是粗心的小明忘记了一 部分的数列,只记得其中 N 个整数。现在给出这 N 个整数,小明想知道包含这 N 个整数的最短的等差数列有 几项?【输入】输入的第一行包含一个整数 N。 第二行包含N个整数A1,A2,···,AN。(注意A1 ∼AN并不一定是按等差数列中的顺序给出)【输出】输出一个整数表示答案【样例输入】52 6 4 10 20【样例输出】10【样例说原创 2020-10-14 19:10:15 · 2344 阅读 · 0 评论 -
小数化分数(C++ 代码讲解很详细)
【问题描述】任何小数都能表示成分数的形式,对于給定的小数,编写程序其化为最简分数输出,小数包括简单小数和循环小数。【输入形式】第一行是一个整数N,表示有多少组数据。每组数据只有一个纯小数,也就是整数部分为0。小数的位数不超过9位,循环部分用()括起来。【输出形式】对每一个对应的小数化成最简分数后输出,占一行【样例输入】30.(4)0.50.32(692307)【样例输出】4/91/217/52解题思路:对于本题的整数部分都是零的1.对于普通不包含循环体的小数(其中有无限不原创 2020-10-02 16:18:15 · 11120 阅读 · 3 评论 -
M进制转N进制(36以内进制数互相转换通用模板)
题目:将m进制数X,转换为n进制数输出输入:输入的第一行包括两个整数:M和N(2<=M,N<=36),下面的一行输入一个数X,X是M进制的数,现在要求你将M进制的数X转换为N进制的数输出。输出:输出X的N进制表示的数。样例输入10 211样例输出1011提示:注意输入时如有字母,则字母为大写,输出时如有字母,则字母为小写。AC代码如下:#include<stdio.h>#include<string.h>int main(){ int m,n,i原创 2020-09-29 19:53:20 · 4649 阅读 · 2 评论 -
Alaska
Problem describe:The Alaska Highway runs 1422 miles from Dawson Creek, British Columbia to Delta Junction, Alaska. Brenda would like to be the first person to drive her new electric car the length of the highway. Her car can travel up to 200 miles once ch原创 2020-05-18 18:20:53 · 1357 阅读 · 0 评论 -
二分查找知识总结
今天写了一个题之后对二分有了不少的了解,二分分为两种,第一种是对一个有序的数组来说,在二分的过程中,先找到第一个比要查的数小于或等于它的数,并返回其下标;第二种是普通的二分,对于有重复的数据,他返回的值就不一定是提上要求的;举个例子 比如我要在2 2 2 2 3 4这6个数中找2的位置,对于第一种方法查询的结果就为1,第二种方法查询的结果就为3;下面上代码。法一:我下面代码是对于给你n个数,然...原创 2019-11-08 18:36:52 · 240 阅读 · 0 评论 -
HDU1716 排列2(全排列)
Ray又对数字的列产生了兴趣:现有四张卡片,用这四张卡片能排列出很多不同的4位数,要求按从小到大的顺序输出这些4位数。Input每组数据占一行,代表四张卡片上的数字(0<=数字<=9),如果四张卡片都是0,则输入结束。Output对每组卡片按从小到大的顺序输出所有能由这四张卡片组成的4位数,千位数字相同的在同一行,同一行中每个四位数间用空格分隔。每组输出数据间空一行,最后一...原创 2020-03-05 11:27:46 · 547 阅读 · 2 评论 -
HUD2080 夹角有多大II(余弦定理)
Problem Description这次xhd面临的问题是这样的:在一个平面内有两个点,求两个点分别和原点的连线的夹角的大小。注:夹角的范围[0,180],两个点不会在圆心出现。Input输入数据的第一行是一个数据T,表示有T组数据。每组数据有四个实数x1,y1,x2,y2分别表示两个点的坐标,这些实数的范围是[-10000,10000]。Output对于每组输入数据,输出夹角的大...原创 2020-03-01 13:29:37 · 379 阅读 · 15 评论 -
Team Formation(位与运算+右移)
For an upcoming programming contest, Edward, the headmaster of Marjar University, is forming a two-man team from N students of his university.Edward knows the skill level of each student. He has foun...原创 2020-02-27 19:41:36 · 381 阅读 · 21 评论 -
May Day Holiday(蔡勒公式)
As a university advocating self-learning and work-rest balance, Marjar University has so many days of rest, including holidays and weekends. Each weekend, which consists of Saturday and Sunday, is a r...原创 2020-02-23 11:03:34 · 880 阅读 · 0 评论 -
HDU-2899 Strange fuction(二分+导数)
Now, here is a fuction:F(x) = 6 * x7+8*x6+7x3+5*x2-yx (0 <= x <=100)Can you find the minimum value when x is between 0 and 100.InputThe first line of the input contains an integer T(1<=T&...原创 2020-02-12 11:48:31 · 183 阅读 · 0 评论 -
Number Sequence(HDU-1005)
Problem DescriptionA number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A, B, and n, you are to calculate the value of f(n).InputThe input ...原创 2020-01-31 12:54:16 · 175 阅读 · 0 评论 -
Biorhythms(中国剩余定理)
DescriptionSome people believe that there are three cycles in a person’s life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they h...原创 2019-09-10 16:04:14 · 326 阅读 · 0 评论 -
高等数学知识总结
因为某些算法题和数学有着密不可分的联系,因此,我决定将我大一这一年来学的高等数学做一个全面的总结,有些知识已经记得不算太清,如果有错误的地方还请大佬及时指出。第一章:函数、极限与连续第1节:初等函数这一节就是高中的一些基本初等函数的的复习,补充几个不是高中的知识。(1)差集:A\B={x|x属于A且x不属于B(属于号不会打,捂脸)},同理B\A与之相反。B\A读作B插A(别想多了)(2)...原创 2019-08-29 17:44:27 · 3584 阅读 · 0 评论 -
Fraction(HDU-5912)
Mr. Frog recently studied how to add two fractions up, and he came up with an evil idea to trouble you by asking you to calculate the result of the formula below:As a talent, can you figure out the a...原创 2019-08-23 09:19:48 · 181 阅读 · 0 评论 -
The area(数学积分法或公式法)
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. Now given all the intersect...原创 2019-08-07 09:05:28 · 661 阅读 · 0 评论 -
反正切函数的应用
反正切函数可展开成无穷级数,有如下公式(其中0 <= x <= 1) 公式(1)使用反正切函数计算PI是一种常用的方法。例如,最简单的计算PI的方法:PI=4arctan(1)=4(1-1/3+1/5-1/7+1/9-1/11+...) 公式(2)然而,这种方法的效率很低,但我们可以根据角度和的正切函数公式:tan(a+b)=[tan(a)+tan(b)]/[1-t...原创 2019-08-01 18:03:24 · 1106 阅读 · 0 评论 -
orders(全排列)
The stores manager has sorted all kinds of goods in an alphabetical order of their labels. All the kinds having labels starting with the same letter are stored in the same warehouse (i.e. in the same ...原创 2019-08-04 15:48:48 · 480 阅读 · 0 评论 -
求任意多边形的面积
首先告诉你求n多边形面积的公式是:S=1/2((x1y2-x2y1)+(x2y3-x3y2)+…+(xn-1yn-xnyn-1))此公式适用于求任意n多边形的面积,甚至有时可以解决,判断多边形顶点的输入顺序,即顺时针或逆时针,看下面代码会给你讲解怎么判断,其实很简单题目链接http://acm.hdu.edu.cn/showproblem.php?pid=2036代码如下:#includ...原创 2019-08-04 15:15:29 · 435 阅读 · 0 评论