
ACM-数学
文章平均质量分 52
路小白_zZ
这个作者很懒,什么都没留下…
展开
-
Codeforces 569A
题意:一首歌有t秒,开始下载了s秒,然后开始播放,q表示经过q秒可以下载q-1秒的歌曲,每次听到下载进度的地方就重新播放,问需要重播几次可以听到完整的歌。 题解:数学题,看了http://blog.youkuaiyun.com/skyword_sun/article/details/47415681的解法才理解。(q-1)/q是下载速度,如果已经有了s秒音乐,当前实际可以听的长度S=s+s*(q-1)/q+s原创 2015-08-14 23:55:44 · 827 阅读 · 0 评论 -
uva 10308(无根树变有根)
题意:给出一些村庄之间的路的距离,每个村庄可以到达任意其他村庄,且所有路中不会有环。问任意两个村庄可达的总路径最长是多少。题解:因为从一个村庄到另一个村庄同一个的村庄不会经过两次,所以村庄和路其实是一棵无根树,用dfs(int a)计算结点a的子结点到a的最大距离,结果就是a的子结点到结点a的最大距离加次大距离。#include #include #include using n原创 2015-01-12 18:41:45 · 805 阅读 · 0 评论 -
uva 10970(数学)
题目:Mohammadhas recently visited Switzerland.As he loves his friends very much, he decided to buy some chocolate for them,but as this fine chocolate is very expensive(You know Mohammad is a little原创 2014-07-16 18:05:08 · 1047 阅读 · 0 评论 -
uva 10790(数学)
题目:inputoutputsample inputsample output原创 2014-07-16 17:25:03 · 743 阅读 · 0 评论 -
uva 846(数学)
题目:inputoutputsample inputsample output原创 2014-07-14 21:01:02 · 812 阅读 · 0 评论 -
uva 113(数学)
题目:Current work in cryptography involves (among other things) large prime numbers and computing powers of numbers modulo functions of these primes. Work in this area has resulted in the practical原创 2014-07-13 19:52:01 · 804 阅读 · 0 评论 -
uva 591(数学)
题目:Little Bob likes playing with his box of bricks. He puts the bricks one upon another and buildsstacks of different height. ``Look, I've built a wall!'', he tells his older sister Alice. ``Nah,原创 2014-07-14 19:55:35 · 781 阅读 · 0 评论 -
uva 621(数学)
题目:At a certain laboratory results of secret research are thoroughly encrypted. A result of a single experiment is stored as an information of its completion:`positive result', `negative res原创 2014-07-14 19:53:21 · 656 阅读 · 0 评论 -
uva 10161(数学)
题目:inputoutputsample inputsample output原创 2014-07-14 19:51:47 · 677 阅读 · 0 评论 -
uva 10499(数学)
题目:n the Land of Justice the selling price of everything is fixed all over the country. Nobody can buy a thing and sell it in double price. But, that created problems for the businessmen. They left原创 2014-07-14 21:03:59 · 842 阅读 · 0 评论 -
uvalive 4636(逻辑)
题意:等大的立方体搭积木,每个立方体可以直接放在地上或放在另一个正方体的正上方,给出正视图和侧视图,问最少要用多少个正方体。题解:可以先想如何形成正视图或侧视图,那么就是二维平面,正视图(侧视图)上有多少个正方形就是有多少个正方体,然后在这个基础上侧视图(正视图)如果出现新的列(之前视图不相等)的,就要新摆放一个,否则通过平移可以看做同一列,就不需要添加正方体了,那么可以得出,最少数量正方体就原创 2015-03-25 19:37:38 · 1282 阅读 · 0 评论 -
uvalive 4253(暴力)
题意:有n个靶子,是平行于x轴的高度不同的线段,给出n个d(高度)、l(左端点)、r(右端点),然后给出w,让在x轴的[0,w]这个区间内射箭,问是否存在一个位置能射中所有靶子。题解:先按高度排序,然后在[0,w]范围内二分位置,先得到射箭到第一个靶子的左右端点的斜率,然后到第二个靶子的左右端点的斜率,比较斜率范围是否可以重叠,如果不可以就在x轴上左移或右移(改变l或r),否则就缩小斜率范围,原创 2015-03-25 21:56:42 · 833 阅读 · 0 评论 -
hdu 4998(解析几何)
题意:一个人要围绕一个点逆时针旋转p1弧度,然后继续围绕下一个点逆时针旋转p2弧度,旋转n次,给出了n个点的坐标和每次旋转的角度,问n次旋转后相当于围绕着哪个点旋转多少弧度,输出它的坐标和度数。弧度不超过2π。题解:几何题还是要靠公式。。。先总结一个点(x0,y0)围绕圆心(a,b)逆时针旋转p度后的坐标(x,y)的解法。 x = a + (x0 - a) * cos(p) - (y0 -原创 2015-03-16 00:36:30 · 619 阅读 · 0 评论 -
uva 645(数学)
题意:给出两个数a和b,不断找出两个整数x和y,使他们的商x/y逐渐逼近a/b,y是从1到b。题解:因为y是从1到b,可以计算出x,然后计算x/y与a/b的差值,让初始差值很大,然后每次差值有减小,就输出这组解。#include #include int a, b;int main() { int cas = 0; while (scanf("%d%d", &a, &b) =原创 2015-04-28 18:50:29 · 556 阅读 · 0 评论 -
acdream 1077(数学)
题意:给出一个数字n,要求不比n大的三个数字的最小公倍数。 题解:最小公倍数要最大,最优是三个最大公约数是1的数字相乘,所以如果n是奇数肯定满足n*(n-1)(n-2)最大,如果n是偶数,就要看n是否能被3整除,如果n % 3 != 0,那么可以满足n(n-1)(n -3)最大,否则(n-3) % 3 == 0,只能取(n-1)(n-2)*(n-3)为解。#include <stdio.h>lo原创 2015-04-30 20:38:00 · 644 阅读 · 0 评论 -
uva 1523
题意:有8个数字全排列后带入公式计算,选出最小值。题解:水题。#include #include #include using namespace std;int flag[8][2] = {{-1, -1}, {-1, 0}, {1, 0}, {1, 1}, {0, -1}, {0, 1}, {-1, 1}, {1, -1}};double arr[8];int main(原创 2015-04-24 23:06:47 · 488 阅读 · 0 评论 -
acdream 1686(数学)
题意:给出了一个钟表上的准确时间,hh:mm:xx,问多少秒后时针和分针能够重合。题解:计算此时分针和时针距离0点的准确角度hd与md,然后每秒分针转动mm = 0.1度,时针转动hh = 1/120,然后如果要分针与时针重合,hd + hh * x = md + mm * x,当hd > md时x即为解,否则先让分针走到0点,然后时针加上相应角度继续用上面的式子计算x。#include原创 2015-04-15 23:17:57 · 789 阅读 · 0 评论 -
uva 769(构造)
题意:给出一个n*n的网格,每个网格上有一张纸,网格是从左到右从上到下编号1~n * n,然后一个人最初站在格子1上,然后左右上下任意走到有纸片的格子上走k1步(k >= 2 * n),拿走一些纸片,保证一定不会拿走此时的落脚点上的纸,然后继续走k2步(k2 >= 2 * n),最后只剩下一张纸就是此时站的位置,输出每次的步数k和拿走的纸的网格编号。题解:这个是有规律的,一行一行的删除,和初始原创 2015-04-23 23:57:11 · 685 阅读 · 0 评论 -
uva 434(逻辑)
题意:有n×n的由边长是1的正方体组成的正视图和侧视图,问此时最少多少个正方体能组成这种正视图和侧视图,还有在最少的基础上最多添加多少个正方体同样形成完全相同的正视图和侧视图。题解:之前有做过一个类似的题求最少个正方体分析在此,推最多个正方体也很简单,就是先根据一种视图填满每一列,然后根据另一个视图将多填的再减掉就可以了。#include #include const int N =原创 2015-04-23 00:44:34 · 882 阅读 · 0 评论 -
uva 1555(数学)
题意:有n个点在一个坐标系内,给出了第一个点的高度H,所有点高度都满足Hi = (H(i-1) + H(i+1)) / 2 - 1且Hi>=0,问第n个点的高度最低是多少,题解:根据公式可以知道这些点之间的距离满足等差序列,d = 2,如果在最低点(Hi = 0)的左边点越多,右边最后一个点的高度就越低,可以在左边根据h = Sn = a1n + (n * (n - 1)) / 2 * d,得原创 2015-04-22 16:38:08 · 496 阅读 · 0 评论 -
hdu 5033(数学)
题意:有一个人在到处是高楼大厦的地方抬头仰望,假设所有高楼都在一条数轴上,给出了高楼的位置和高度,然后给出了人的位置(高度为0.....),问人能看到的阳光的最大角度是多少。题解:因为人的位置还会变化,纯暴力会超时,所以把高楼和人的位置都整合到一起,按位置排序,然后从左到右根据高楼之间位置和高度的比例,将可能成为最大角度的楼都放到栈里,如果是人就根据栈内的所有值得出左边最大角度的余角,然后逆序原创 2015-03-14 12:08:13 · 630 阅读 · 0 评论 -
hdu 5053(水题)
题意:给出a、b,计算[a,b]所有整数的立方和。题解:只是为了证明今天有在做题Orz。#include __int64 a, b;int main() { int t, cas = 1; scanf("%d", &t); while (t--) { scanf("%d%d", &a, &b); __int64 sum = 0; for (__int64 i = a原创 2015-03-13 20:15:16 · 528 阅读 · 0 评论 -
uva 107(数学)
题目:A clever cat walks into a messy room which he needs to clean. Instead of doing the work alone, it decides to have its helper cats do the work. It keeps its (smaller) helper cats inside its hat.原创 2014-07-14 20:05:04 · 737 阅读 · 0 评论 -
uva 573(数学)
题目:inputoutputsample inputsample output原创 2014-07-14 20:40:29 · 732 阅读 · 0 评论 -
uva 10879(数学)
题解:直接算比1大的因子原创 2014-07-17 21:07:09 · 890 阅读 · 0 评论 -
uva 350(数学)
题解:注意#include #include using namespace std;int main() { int z, i, m, l, flag, temp[100010], t = 1, j; while (scanf("%d%d%d%d", &z, &i, &m, &l) && (z || i || m || l)) { flag = 0; temp[0] =原创 2014-07-17 20:02:24 · 921 阅读 · 0 评论 -
uva 408(数学)
题解:quyici#include #include using namespace std;int main() { int step, mod, seed, flag, n; while (scanf("%d%d", &step, &mod) != EOF) { seed = flag = n = 0; while (1) { flag++; seed = (s原创 2014-07-17 19:28:50 · 1073 阅读 · 0 评论 -
uva 575(数学)
题解:题目中已给公式,循环#include #include #include #include using namespace std;const int N =50;int main() { char s[N]; int ans; while (scanf("%s", s)) { if (s[0] == '0') break; ans = 0; int l原创 2014-07-17 18:37:21 · 853 阅读 · 0 评论 -
uva 253(数学)
题解:将前六个后六个字符分开存原创 2014-07-16 18:24:06 · 878 阅读 · 0 评论 -
uva 10177(数学)
题目:You can see a (4x4) grid below. Can you tell me how many squares and rectangles are hidden there? You can assume that squares are not rectangles. Perhaps one can count it by hand but can you co原创 2014-07-16 17:55:46 · 855 阅读 · 0 评论 -
uva 10719(数学)
题目:inputoutputsample inputsample output原创 2014-07-16 17:36:53 · 897 阅读 · 0 评论 -
uva 11044(数学)
题目:inputoutputsamle inputsample output原创 2014-07-16 17:26:33 · 638 阅读 · 0 评论 -
uva 10014(数学)
题目:There is a sequence ofn+2 elements a0, a1,…, an+1(n i 1000). It is known thatai= (ai–1 + ai+1)/2 – ci for each i=1, 2, ..., n. You are given a0, an+1,c1, ... , cn. Write a program which cal原创 2014-07-16 18:14:06 · 701 阅读 · 0 评论 -
uva 550(数学)
题解:因为weiz#include #include using namespace std;int main() { int n, a, b, temp, flag, t, k; while (scanf("%d%d%d", &n, &a, &b) != EOF) { flag = temp = k = 0; t = a; while (1) { flag++;原创 2014-07-17 18:50:19 · 875 阅读 · 0 评论 -
uva 568(数学)
题解:从1开始乘到n,因为结果只要最后一位,所以每乘完一次,只要保留后5位(少了值会不准确,刚开始只保留了一位,结果到15就错了,保留多了int会溢出,比如3125就会出错) 和下一个数相乘,接着保留5位,注意5位没有后导零,最后取5位中最后一个不是零的就可以了。#include #include using namespace std;int main() { int n;原创 2014-07-17 18:58:00 · 1301 阅读 · 0 评论 -
uva 10392(数学)
题解:#include #include using namespace std;int main() { long long int n, temp; int flag; while (scanf("%lld", &n) && n > 0) { temp = sqrt(n); flag = 0; for (long long int i = 2; i <= temp原创 2014-07-18 19:14:22 · 770 阅读 · 0 评论 -
uva 10916(数学)
题解:2#include #include int main() { int n, i; double m, ans; while (scanf("%d", &n) && n) { n = (n - 1960) / 10 + 2; m = pow(2, n); double ans = 0; for (i = 1;; i++) { ans += log(i)原创 2014-07-19 17:46:06 · 968 阅读 · 0 评论 -
uva 579(数学)
题解:将分针的角度减#include #include int main() { double m1, m2, m; double ans, h; while (scanf("%lf:%lf", &h, &m) && (h || m)) { double temp1 = m * 6; double temp2 = h * 30 + 30 * temp1 / 360; d原创 2014-07-19 17:42:56 · 811 阅读 · 0 评论 -
uva 375(数学)
题解:在一个等腰三角形内找到内切圆半径原创 2014-07-19 17:38:31 · 1112 阅读 · 0 评论 -
uva 10010(数学)
题解:有n个灯,一个人来回走n次,每次原创 2014-07-19 15:54:23 · 764 阅读 · 0 评论