数学
Ypopstar
这个作者很懒,什么都没留下…
展开
-
LeetCode--136--只出现一次的数字
题目描述:给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。说明:你的算法应该具有线性时间复杂度。 你可以不使用额外空间来实现吗?输入:[2,2,1][4,1,2,1,2]输出:14题意:题目描述题解:异或一下,相同的数异或一定为0代码:class Solution { public int singleNumber(int[] nums) { int ans = 0; int len原创 2020-06-20 21:32:24 · 66 阅读 · 0 评论 -
LeetCode--292--Nim 游戏
题目描述:你和你的朋友,两个人一起玩 Nim 游戏:桌子上有一堆石头,每次你们轮流拿掉 1 - 3 块石头。 拿掉最后一块石头的人就是获胜者。你作为先手。你们是聪明人,每一步都是最优解。 编写一个函数,来判断你是否可以在给定石头数量的情况下赢得游戏。输入:4输出:false题意:题目描述题解:数学题。如果堆中石头的数量 nn 不能被 44 整除,那么你总是可以赢得 Nim 游戏的胜利。代码:class Solution { public boolean canWinNim(原创 2020-06-17 21:45:23 · 77 阅读 · 0 评论 -
牛客网--14335--Stack
题目描述:栈作为一种数据结构,是一种只能在一端进行插入和删除操作的特殊线性表。它按照后进先出的原则存储数据,先进入的数据被压入栈底,最后的数据在栈顶,需要读数据的时候从栈顶开始弹出数据(最后一个数据被第一个读出来)。现在给出要入栈的元素数n,每种元素各不相同,求不同的出栈序列数目。输入描述:要入栈的元素数n,处理到文件尾1<=n<=100输出描述:出栈序列方案数,结果对1000000007取模.输入:13输出:15题意:题目描述题解:卡特兰数代码:#in原创 2020-06-07 19:14:02 · 142 阅读 · 0 评论 -
牛客网--14682--求交集
题目描述:约数个数的和输入描述:给个n,求1到n的所有数的约数个数的和~输出描述:输出一个整数,表示答案输入:2 31 31 2 3输出:1 3题意:题目描述题解:直接推出来的代码:#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>using namespace std;int main(){ int n; w原创 2020-06-07 19:12:04 · 81 阅读 · 0 评论 -
牛客网--14743--qwb的骚扰
题目描述:自从学姐拒绝了qwb之后,qwb开始了疯狂的骚扰。qwb来到了一个公共电话亭,他摸摸口袋只有n元钱。已知该公用电话的规则是,前3分钟一共收费x元(不到3分钟也要收x元),超过3分钟每分钟收费y元(不到1分钟也要收y元)。(先扣钱再打电话。)那么问题来了,qwb最多骚扰学姐几分钟?(假设学姐不会挂qwb电话)输入描述:第一行输入一个整数T,表示数据组数,接下来T行,每行三个整数n,x,y 。输出描述:每行输出一个整数,表示qwb最多骚扰学姐的分钟数。输入:210 5 15 4原创 2020-05-31 20:37:08 · 340 阅读 · 0 评论 -
牛客网--207422--面积
题目描述:正方形周围接4个半圆,求图形的面积输入描述:输入t,代表有t组数据。每组数据输入正整数x,代表正方形的边长。(t<100, x<1000)输出描述:输出图形面积,并保留2位小数,其中π取3.14。 输入:11输出:2.57题意:题目描述题解:直接算代码:#include<cstring>#include<iostream>#include<cstdio>#include<algorithm>usin原创 2020-05-31 20:34:02 · 169 阅读 · 0 评论 -
HDOJ--2067--小兔的棋盘
题目描述:小兔的叔叔从外面旅游回来给她带来了一个礼物,小兔高兴地跑回自己的房间,拆开一看是一个棋盘,小兔有所失望。不过没过几天发现了棋盘的好玩之处。从起点(0,0)走到终点(n,n)的最短路径数是C(2n,n),现在小兔又想如果不穿越对角线(但可接触对角线上的格点),这样的路径数有多少?小兔想了很长时间都没想出来,现在想请你帮助小兔解决这个问题,对于你来说应该不难吧!输入描述:每次输入一个数n(1<=n<=35),当n等于-1时结束输入。输出描述:对于每个输入数据输出路径数,具体格式看原创 2020-05-25 18:38:47 · 143 阅读 · 0 评论 -
HDOJ--2075--A|B?
题目描述:正整数A是否能被正整数B整除,不知道为什么xhd会研究这个问题,来帮帮他吧。输入描述:输入数据的第一行是一个数据T,表示有T组数据。每组数据有两个正整数A和B(A,B<10^9)。输出描述:对于每组输入数据,输出"YES"表示可以被整除,"NO"表示不能被整除。输入:24 25 3输出:YESNO题意:字面意思题解:傻逼题代码:#include<cstdio>#include<cstring>#include<iostr原创 2020-05-13 23:10:43 · 293 阅读 · 0 评论 -
HDOJ--1868--Consecutive sum
题目描述:Every body knew that 15 = 1+2+3+4+5 = 4+5+6 = 7+8. Now give you a number N, tell me how many ways to represent N as a sum of consecutive positive integers. For example, 15 have 3 ways to be found.输入描述:Each line will contain an signed 32-bits intege原创 2020-05-12 17:13:08 · 92 阅读 · 0 评论 -
HDOJ--1222--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 first hole he get into is ...原创 2020-05-06 18:12:15 · 137 阅读 · 0 评论 -
HDOJ--1215--七夕节
题目描述:七夕节那天,月老来到数字王国,他在城门上贴了一张告示,并且和数字王国的人们说:“你们想知道你们的另一半是谁吗?那就按照告示上的方法去找吧!”人们纷纷来到告示前,都想知道谁才是自己的另一半.告示如下:数字N的因子就是所有比N小又能被N整除的所有正整数,如12的因子有1,2,3,4,6.你想知道你的另一半吗?输入描述:输入数据的第一行是一个数字T(1<=T<=5000...原创 2020-05-06 18:11:01 · 107 阅读 · 0 评论 -
HDOJ--1999--不可摸数
题目描述:s(n)是正整数n的真因子之和,即小于n且整除n的因子和.例如s(12)=1+2+3+4+6=16.如果任何数m,s(m)都不等于n,则称n为不可摸数.输入描述:包含多组数据,首先输入T,表示有T组数据.每组数据1行给出n(2<=n<=1000)是整数。输出描述:如果n是不可摸数,输出yes,否则输出no输入:3258输出:yesyesno题意...原创 2020-05-06 18:09:44 · 134 阅读 · 0 评论 -
HDOJ--1018--Big Number
题目描述:In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number,...原创 2020-05-04 19:26:48 · 98 阅读 · 0 评论 -
HDOJ--1061--Rightmost Digit
题目描述:Given a positive integer N, you should output the most right digit of N^N.输入描述:The input contains several test cases. The first line of the input is a single integer T which is the number of t...原创 2020-05-04 19:22:21 · 140 阅读 · 1 评论 -
HDOJ--1060--Leftmost Digit
题目描述:Given a positive integer N, you should output the leftmost digit of N^N.输入描述:The input contains several test cases. The first line of the input is a single integer T which is the number of tes...原创 2020-05-04 19:20:32 · 82 阅读 · 0 评论 -
HDOJ--1787--GCD Again
题目描述:Do you have spent some time to think and try to solve those unsolved problem after one ACM contest?No? Oh, you must do this when you want to become a “Big Cattle”.Now you will find that this p...原创 2020-04-29 18:57:40 · 85 阅读 · 0 评论 -
HDOJ--2521--反素数
题目描述:反素数就是满足对于任意i(0<i<x),都有g(i)<g(x),(g(x)是x的因子个数),则x为一个反素数。现在给你一个整数区间[a,b],请你求出该区间的x使g(x)最大。输入描述:第一行输入n,接下来n行测试数据输入包括a,b, 1<=a<=b<=5000,表示闭区间[a,b].输出描述:输出为一个整数,为该区间因子最多的数.如果满足...原创 2020-04-29 18:54:10 · 167 阅读 · 0 评论 -
Codeforces--318A--Even Odds
题目描述:Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rea...原创 2020-04-18 22:30:35 · 230 阅读 · 0 评论 -
Codeforces--1283B--Candies Division
题目描述:Santa has n candies and he wants to gift them to k kids. He wants to divide as many candies as possible between all k kids. Santa can’t divide one candy into parts but he is allowed to not use s...原创 2020-04-18 22:29:24 · 248 阅读 · 0 评论 -
Codeforces--519C--A and B and Team Training
题目描述:A and B are preparing themselves for programming contests.An important part of preparing for a competition is sharing programming knowledge from the experienced members to those who are just be...原创 2020-04-18 22:25:52 · 184 阅读 · 0 评论 -
Codeforces--762A--k-th divisor
题目描述:You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn’t exist.Divisor of n is any such natural number, that n can be divided by it without remainder.输入描述...原创 2020-04-18 22:24:17 · 207 阅读 · 0 评论 -
Codeforces--1291A--Even But Not Even
题目描述:Let’s define a number ebne (even but not even) if and only if its sum of digits is divisible by 2 but the number itself is not divisible by 2. For example, 13, 1227, 185217 are ebne numbers, whi...原创 2020-04-18 22:22:49 · 173 阅读 · 0 评论 -
Codeforces--1076C--Meme Problem
题目描述:Try guessing the statement from this picture:You are given a non-negative integer d. You have to find two non-negative real numbers a and b such that a+b=d and a⋅b=d.输入描述:The first line conta...原创 2020-04-18 22:18:11 · 148 阅读 · 0 评论 -
Codeforces--1A--Theatre Square
题目描述:Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city’s anniversary, a decision was taken to pave the Square with square g...原创 2020-04-17 22:29:05 · 189 阅读 · 0 评论 -
Codeforces--50A--Domino piling
题目描述:You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to plac...原创 2020-04-17 22:27:28 · 295 阅读 · 1 评论 -
Codeforces--707C--Pythagorean Triples
题目描述:Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a rig...原创 2020-04-17 22:25:41 · 132 阅读 · 0 评论 -
Codeforces--735D--Taxes
题目描述:Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal to n (n ≥ 2) burles and the amount of tax he has to pay is calculated as the...原创 2020-04-17 22:20:01 · 201 阅读 · 0 评论 -
Codeforces--466C--Number of Ways
题目描述:You’ve got array a[1], a[2], …, a[n], consisting of n integers. Count the number of ways to split all the elements of the array into three contiguous parts so that the sum of elements in each pa...原创 2020-04-16 23:16:14 · 187 阅读 · 0 评论 -
Codeforces--849B--Tell Your World
题目描述:Connect the countless points with lines, till we reach the faraway yonder.There are n points on a coordinate plane, the i-th of which being (i, yi).Determine whether it’s possible to draw two ...原创 2020-04-16 23:03:46 · 103 阅读 · 0 评论 -
Codeforces--1335A--Candies and Two Sisters
题目描述:There are two sisters Alice and Betty. You have n candies. You want to distribute these n candies between two sisters in such a way that:Alice will get a (a>0) candies;Betty will get b (b&g...原创 2020-04-14 23:00:24 · 491 阅读 · 0 评论 -
HDOJ--2073--无限的路
题目描述:甜甜从小就喜欢画图画,最近他买了一支智能画笔,由于刚刚接触,所以甜甜只会用它来画直线,于是他就在平面直角坐标系中画出如下的图形:甜甜的好朋友蜜蜜发现上面的图还是有点规则的,于是他问甜甜:在你画的图中,我给你两个点,请你算一算连接两点的折线长度(即沿折线走的路线长度)吧。输入描述:第一个数是正整数N(≤100)。代表数据的组数。每组数据由四个非负整数组成x1,y1,x2,y2;所...原创 2020-04-14 22:51:50 · 103 阅读 · 0 评论 -
Codeforces--1294C--Product of Three Numbers
题目描述:You are given one integer number n. Find three distinct integers a,b,c such that 2≤a,b,c and a⋅b⋅c=n or say that it is impossible to do it.If there are several answers, you can print any.You h...原创 2020-04-02 20:21:00 · 184 阅读 · 0 评论 -
Codeforces--1203C--Common Divisors
题目描述:You are given an array a consisting of n integers.Your task is to say the number of such positive integers x such that x divides each number from the array. In other words, you have to find the...原创 2020-04-02 19:13:41 · 298 阅读 · 0 评论 -
HDOJ--4811--Ball
题目描述:Jenny likes balls. He has some balls and he wants to arrange them in a row on the table.Each of those balls can be one of three possible colors: red, yellow, or blue. More precisely, Jenny has ...原创 2020-04-02 14:54:11 · 128 阅读 · 0 评论 -
HDOJ--5744--Keep On Movin
题目描述:Professor Zhang has kinds of characters and the quantity of the i-th character is ai. Professor Zhang wants to use all the characters build several palindromic strings. He also wants to maximize...原创 2020-04-01 11:44:38 · 91 阅读 · 0 评论 -
HDOJ--5974--A Simple Math Problem
题目描述:Given two positive integers a and b,find suitable X and Y to meet the conditions:X+Y=aLeast Common Multiple (X, Y) =b输入描述:Input includes multiple sets of test data.Each test data occupies on...原创 2020-03-31 20:11:36 · 100 阅读 · 0 评论 -
HDOJ--5776--sum
题目描述:Given a sequence, you’re asked whether there exists a consecutive subsequence whose sum is divisible by m. output YES, otherwise output NO输入描述:The first line of the input has an integer T (1≤T...原创 2020-03-31 19:10:16 · 85 阅读 · 0 评论 -
HDOJ--6124--Euler theorem
题目描述:HazelFan is given two positive integers a,b, and he wants to calculate amodb. But now he forgets the value of b and only remember the value of a, please tell him the number of different possible...原创 2020-03-31 11:25:30 · 148 阅读 · 1 评论 -
HDOJ--5665--Lucky
题目描述:Chaos August likes to study the lucky numbers.For a set of numbers S,we set the minimum non-negative integer,which can’t be gotten by adding the number in S,as the lucky number.Of course,each n...原创 2020-03-31 11:15:44 · 82 阅读 · 0 评论 -
牛客网--14399--素数判断
题目描述:给出一个数x,判断它是否为素数,并输出所有它的素因子。输入描述:第1行输入组数T,代表有T组数据。第2-T+1行输入一个数x。数据保证:2≤x≤109输出描述:每行输出两行,对应输入行的结果。第1行,如果x是素数,输出“isprime”(不含双引号),否则输出“noprime”(不含双引号)。第2行,输出x的素因子。输入:32910输出:isprime2...原创 2020-03-30 14:00:31 · 959 阅读 · 0 评论