找规律&数学
我在浪里
I LOVE Coding,冲刺中。。。
展开
-
leetcode t6-Z 字形变换
6. Z 字形变换难度中等684收藏分享切换为英文关注反馈将一个给定字符串根据给定的行数,以从上往下、从左到右进行Z 字形排列。比如输入字符串为"LEETCODEISHIRING"行数为 3 时,排列如下:L C I RE T O E S I I GE D H N之后,你的输出需要从左往右逐行读取,产生出一个新的字符串,比如:"LCIRETOESIIGEDHN"。请你实现这个将字符串进行指定行数变换的函数:string convert(st...原创 2020-05-27 17:47:32 · 146 阅读 · 0 评论 -
poj3101——Astronomy(大数数学&gcd)
AstronomyTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 5932 Accepted: 1337DescriptionThere are n planets in the planetary system of star X. They orbit原创 2017-05-04 15:22:10 · 754 阅读 · 0 评论 -
hdu4497——GCD and LCM(数论&容斥原理or排列组合)
GCD and LCM Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2710 Accepted Submission(s): 1186Problem DescriptionGiven two positiv原创 2017-04-22 22:10:30 · 499 阅读 · 0 评论 -
hzau1202——GCD(斐波那契&矩阵快速幂)
1202: GCDTime Limit: 1 Sec Memory Limit: 1280 MBSubmit: 184 Solved: 26[Submit][Status][Web Board]DescriptionInput The first line is an positive integer T . (1Output原创 2017-04-24 19:18:25 · 314 阅读 · 0 评论 -
2的次幂表示(递归)
问题描述 任何一个正整数都可以用2进制表示,例如:137的2进制表示为10001001。 将这种2进制表示写成2的次幂的和的形式,令次幂高的排在前面,可得到如下表达式:137=2^7+2^3+2^0 现在约定幂次用括号来表示,即a^b表示为a(b) 此时,137可表示为:2(7)+2(3)+2(0) 进一步:7=2^2+2+2^0 (2^1用2表示) 3=2+2^0 ...原创 2019-02-17 11:38:38 · 158 阅读 · 0 评论 -
Z字形扫描(找规律+模拟)
时间限制: 2.0s 内存限制: 256.0MB 问题描述: 问题描述 在图像编码的算法中,需要将一个给定的方形矩阵进行Z字形扫描(Zigzag Scan)。给定一个n×n的矩阵,Z字形扫描的过程如下图所示: 对于下面的4×4的矩阵, 1 5 3 9 3 7 5 6 9 4 6 4 7 3 1 3 ...原创 2019-02-22 22:13:18 · 1443 阅读 · 0 评论 -
13-2 骰子谜题
小明参加了少年宫的一项趣味活动:每个小朋友发给一个空白的骰子(它的6个面是空白的,没有数字),要小朋友自己设计每个面写哪个数字。但有如下要求:1. 每个面只能填写 0 至 8 中的某一个数字。2. 不同面可以填写同样的数字,但6个面总和必须等于24。填好后,小朋友可以用自己填写好数字的骰子向少年宫的两个机器人挑战----玩掷骰子游戏。规则如下:三方同时掷出自...原创 2019-05-11 23:37:53 · 325 阅读 · 0 评论 -
13-3 埃及分数
古埃及曾经创造出灿烂的人类文明,他们的分数表示却很令人不解。古埃及喜欢把一个分数分解为类似: 1/a + 1/b 的格式。 这里,a 和 b 必须是不同的两个整数,分子必须为 1 比如,2/15 一共有 4 种不同的分解法(姑且称为埃及分解法):1/8 + 1/1201/9 + 1/451/10 + 1/301/12 + 1/20 那么, 2/45 一共有...原创 2019-05-12 13:56:28 · 258 阅读 · 0 评论 -
立方体堆塔(DP/记忆化搜索)
dp[i][j]:第i层用第j种方块的方案数#include<stdio.h>#include<string.h>#include<math.h>#define mod 1000000007int dp[500][2],n;int dfs(int w, int b,int lev,int op){ if(dp...原创 2019-06-03 10:59:50 · 480 阅读 · 0 评论 -
sdut2878——Circle(高斯消元求期望)
CircleTime Limit: 2000ms Memory limit: 65536K 有疑问?点这里^_^题目描述You have been given a circle from 0 to n - 1. If you are currently at x, you will move to (x - 1) mod n or (x + 1) mod原创 2017-04-20 19:42:18 · 277 阅读 · 0 评论 -
CSU1803——2016(思路)
1803: 2016Submit Page Summary Time Limit: 5 Sec Memory Limit: 128 Mb Submitted: 1201 Solved: 689 Description 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量:原创 2017-05-02 16:44:34 · 311 阅读 · 0 评论 -
hdu4586——Play the Dice
Play the DiceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 3072 Accepted Submission(s): 985Special JudgeProblem DescriptionTher原创 2017-04-12 16:59:21 · 402 阅读 · 0 评论 -
zoj3948——Marjar Cola
Marjar ColaTime Limit: 1 Second Memory Limit: 65536 KBMarjar Cola is on sale now! In order to attract more customers, Edward, the boss of Marjar Company, decides to launch a promotion: If原创 2017-04-12 20:44:07 · 234 阅读 · 0 评论 -
sdut3257——Square Number(打表)
Square NumberTime Limit: 1000MS Memory Limit: 65536KBSubmit Statistic DiscussProblem DescriptionIn mathematics, a square number is an integer that is the square of an integer. In other原创 2017-04-28 20:17:22 · 474 阅读 · 0 评论 -
hdu5245——Joyful(概率论求期望)
JoyfulTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1198 Accepted Submission(s): 528Problem DescriptionSakura has a very magica原创 2017-04-29 17:40:57 · 412 阅读 · 0 评论 -
hdu5241——Friends(找规律+大数幂)
FriendsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1326 Accepted Submission(s): 623Problem DescriptionMike has many friends原创 2017-04-29 17:55:12 · 646 阅读 · 0 评论 -
山科校赛——有解吗?(数学提公因式)
问题 D: 有解吗?时间限制: 1 Sec 内存限制: 128 MB提交: 410 解决: 134[提交][状态][讨论版]题目描述给出方程 a * 1234567 + b * 123456 + c * 1234 = n。其中 a、b、c 均为非负整数变量,n(1 10 ^ 9)为给出整数常量。判断方程是否有解。 输入一个整数 n 输原创 2017-05-01 16:01:22 · 324 阅读 · 0 评论 -
hdu5974——A Simple Math Problem(gcd推导+数学+解方程组)
Given two positive integers a and b,find suitable X and Y to meet the conditions: X+Y=a Least Comm原创 2017-05-01 15:02:04 · 761 阅读 · 0 评论 -
斐波那契
转自:http://www.aichengxu.com/cyvyan/17027.htm问题描述斐波那契数列大家都非常熟悉。它的定义是:f(x) = 1 .... (x=1,2)f(x) = f(x-1) + f(x-2) .... (x>2)对于给定的整数 n 和 m,我们希望求出:f(1) + f(2) + ... + f(n) 的值。但这个值可转载 2017-04-06 16:36:50 · 363 阅读 · 0 评论 -
山科校赛——求个最大值(打表)
问题 J: 求个最大值时间限制: 1 Sec 内存限制: 128 MB提交: 234 解决: 40[提交][状态][讨论版]题目描述给出 n(1 一直到 n,求满足 ai >= aj 的最大的 ai % aj。 输入第一行一个数字 n,第二行 n 个整数。 输出题目要求的最大值。 样例输入22 3样原创 2017-05-01 16:45:20 · 354 阅读 · 0 评论 -
sdut2605——A^X mod P
A^X mod PTime Limit: 5000ms Memory limit: 65536K 有疑问?点这里^_^题目描述It's easy for ACMer to calculate A^X mod P. Now given seven integers n, A, K, a, b, m, P, and a function f(x) whic原创 2017-04-19 21:59:31 · 242 阅读 · 0 评论 -
hdu5105——Math Problem
Math ProblemTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3019 Accepted Submission(s): 720Problem DescriptionHere has an functi原创 2017-04-16 21:03:31 · 194 阅读 · 0 评论 -
HDU 4507 吉哥系列故事——恨7不成妻 数位DP
吉哥系列故事——恨7不成妻Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 746 Accepted Submission(s): 227Problem Description 单身! 依然单身! 吉哥依原创 2017-04-15 22:03:01 · 278 阅读 · 0 评论 -
蓝桥杯——连号区间数
连号区间数小明这些天一直在思考这样一个奇怪而有趣的问题:在1~N的某个全排列中有多少个连号区间呢?这里所说的连号区间的定义是:如果区间[L, R] 里的所有元素(即此排列的第L个到第R个元素)递增排序后能得到一个长度为R-L+1的“连续”数列,则称这个区间连号区间。当N很小的时候,小明可以很快地算出答案,但是当N变大的时候,问题就不是那么简单了,现在小明需要你的帮助。输入格式:原创 2017-04-07 10:25:06 · 209 阅读 · 0 评论