随笔分类 -  math

养鸡场
摘要:Problem DescriptionJason买来了n米长的竹篱笆,打算将n米长的竹篱笆全部用来围成一个三角形的养鸡场。为方便起见,养鸡场三条边的长度都为正整数。同时,他想让自己的养鸡场看起来更美观一些,要求三条边的长度分别在一个区间范围内。现在,他想知道有多少种不同的方案使得围成的养鸡场满足要求? Input输入包含多组数据。输入数据第一行是一个正整数n,表示竹篱笆的长度。在接下来三行中,第i行的两个正整数为xi,yi。表示三角形的第i条边的边长ai的范围在[xi,yi]内。注意:Jason规定a1≤a2≤a3。 Output输出一个整数,表示满足要求的不同方案数。约定:对于第二行至第四行 阅读全文

posted @ 2013-09-18 10:46 forevermemory 阅读(248) 评论(0) 推荐(0)

简单的等式
摘要:Problem Description现在有一个等式如下:x^2+s(x,m)x-n=0。其中s(x,m)表示把x写成m进制时,每个位数相加的和。现在,在给定n,m的情况下,求出满足等式的最小的正整数x。如果不存在,请输出-1。 Input有T组测试数据。以下有T(T#include#includeusing namespace std;#define ll __int64ll lmx(int x,int m){ll temp=x,sum=0;while(temp){ sum+=temp%m; temp/=m;}return sum;}int main(){ int test;ll n,m,x 阅读全文

posted @ 2013-09-17 20:27 forevermemory 阅读(183) 评论(0) 推荐(0)

Good Numbers
摘要:Problem DescriptionIf we sum up every digit of a number and the result can be exactly divided by 10, we say this number is a good number.You are required to count the number of good numbers in the range from A to B, inclusive.InputThe first line has a number T (T #include#define ll __int64using name 阅读全文

posted @ 2013-09-12 20:35 forevermemory 阅读(479) 评论(0) 推荐(0)

中南月赛试题Decimal
摘要:Description任意一个分数都是有理数,对于任意一个有限小数,我们都可以表示成一个无限循环小数的形式(在其末尾添加0),对于任意一个无限循环小数都可以转化成一个分数。现在你的任务就是将任意一个无限循环小数转化成既约分数形式。所谓既约分数表示,分子和分母的最大公约数是1。Input有多组数据。每组数据一行。输入为0.a1a2a3...ak(b1b2...bm)的形式,其中a1a2a3...ak为非循环部分,(b1b2b3..bm)为循环部分。数据保证非循环部分的长度k和循环部分的长度m不会超过8.Output对于每组测试数据输出A/B,其中A是分子,B是分母,A,B均为整数。Sample 阅读全文

posted @ 2013-09-04 21:34 forevermemory 阅读(223) 评论(0) 推荐(0)

Matrix Chain Multiplication
摘要:Problem DescriptionMatrix multiplication problem is a typical example of dynamical programming. Suppose you have to evaluate an expression like A*B*C*D*E where A,B,C,D and E are matrices. Since matrix multiplication is associative, the order in which multiplications are performed is arbitrary. Ho... 阅读全文

posted @ 2013-06-16 17:32 forevermemory 阅读(265) 评论(0) 推荐(0)

Max Kingdom
摘要:Problem DescriptionMax is the king of the universe, he rules billions of planets. In each planet, there may be several residents. Residents of Max's kingdom will never die, so some of them may be as old as the universe (It is a magic world, isn't it?). One day, Max wants to know how intelleg 阅读全文

posted @ 2013-06-06 01:28 forevermemory 阅读(372) 评论(0) 推荐(0)

Developing School's Contest 2012-2 by HUT:数字游戏
摘要:数字游戏Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other)Total Submission(s) : 178 Accepted Submission(s) : 58Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem Description小艾和小牛在上数学课的时候觉得非常的无聊,于是他们想出了一个新的游戏,小牛写下N位的数字,小艾的任务就是在去除了K位后得到一个最大的数。Input输入有多组数据。第一行输入一个N和. 阅读全文

posted @ 2013-06-03 00:58 forevermemory 阅读(267) 评论(0) 推荐(0)

Crazy Search
摘要:DescriptionMany people like to solve hard puzzles some of which may lead them to madness. One such puzzle could be finding a hidden prime number in a given text. Such number could be the number of different substrings of a given size that exist in the text. As you soon will discover, you really need 阅读全文

posted @ 2013-06-02 21:38 forevermemory 阅读(407) 评论(0) 推荐(0)

青蛙的约会(模线性方程)
摘要:Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,你被要求写一个程序来判断这两只青蛙是否能够碰面,会在什么时候碰面。 我们把这两只青蛙分别叫做青蛙A和青蛙B,并且规定纬度线上东经0度处为原点,由东往西为正方向,单位长度1米,这样 阅读全文

posted @ 2013-05-24 20:08 forevermemory 阅读(244) 评论(0) 推荐(0)

A/B
摘要:Problem Description要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。Input数据的第一行是一个T,表示有T组数据。 每组数据有两个数n(0 <= n < 9973)和B(1 <= B <= 10^9)。Output对应每组数据输出(A/B)%9973。Sample Input2 1000 53 87 123456789Sample Output7922 6060题解:用扩展欧几里得算法解模线性方程#include<iostream>#include&l 阅读全文

posted @ 2013-05-24 16:21 forevermemory 阅读(168) 评论(0) 推荐(0)

蛇形数
摘要:Description: 将数列1.2,3,……,n*n,依次按蛇形方式存在二维数组A[1..n,1..n]中。Input:输入有多组数据,每组数据为一个整数n,( 0< n < 30 )以EOF结束。Output:按照样例格式打印出每组蛇形数,每个数据占有四个域宽,两个数据之间没有空格隔开。两组数据之间有一个换行。Sample Input:145Sample Output: 1 1 2 6 7 3 5 8 13 4 9 12 14 10 11 15 16 1 2 6 7 15 3 5 8 14 16 4... 阅读全文

posted @ 2013-05-07 10:45 forevermemory 阅读(383) 评论(0) 推荐(0)

C Looooops
摘要:DescriptionA Compiler Mystery: We are given a C-language style for loop of typefor (variable = A; variable != B; variable += C) statement;I.e., a loop which starts by setting variable to value A and while variable is not equal to B, repeats statement followed by increasing the variable by C. We wa.. 阅读全文

posted @ 2013-05-04 00:06 forevermemory 阅读(180) 评论(0) 推荐(0)

The 3n + 1 problem
摘要:Problem DescriptionProblems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will be analyzing a property of an algorithm whose classification is not known for all possible inputs.Consider the following algor. 阅读全文

posted @ 2013-05-01 21:16 forevermemory 阅读(95) 评论(0) 推荐(0)

Visible Lattice Points
摘要:DescriptionA lattice point (x, y) in the first quadrant (x and y are integers greater than or equal to 0), other than the origin, is visible from the origin if the line from (0, 0) to (x, y) does not pass through any other lattice point. For example, the point (4, 2) is not visible since the line fr 阅读全文

posted @ 2013-05-01 19:31 forevermemory 阅读(270) 评论(0) 推荐(0)

Relatives
摘要:DescriptionGiven n, a positive integer, how many positive integers less than n are relatively prime to n? Two integers a and b are relatively prime if there are no integers x > 1, y > 0, z > 0 such that a = xy and b = xz.InputThere are several test cases. For each test case, standard input 阅读全文

posted @ 2013-05-01 16:58 forevermemory 阅读(279) 评论(0) 推荐(0)

数学
摘要:Description给出数列A1,A2,...,AN,并设现要求把所有的Bi算出来。Input 输入包含多组测试数据。对于每组数据,第1行,1个整数N(1≤N≤100,000),表示数列的长度。第2行,N个整数A1,A2,...,AN(1≤Ai≤109),表示给出的数列。输入以一个0表示结尾。Output对于每组数据,输出一行,N个整数用空格分隔,表示算出的B1,B2,...,BN。Sample Input31 2 30Sample Output6 3 2数学题采用两边夹的方法一个for#include<stdio.h>long long a[1000005];long long 阅读全文

posted @ 2013-03-17 08:39 forevermemory 阅读(127) 评论(0) 推荐(0)

猪的安家
摘要:Problem DescriptionAndy和Mary养了很多猪。他们想要给猪安家。但是Andy没有足够的猪圈,很多猪只能够在一个猪圈安家。举个例子,假如有16头猪,Andy建了3个猪圈,为了保证公平,剩下1头猪就没有地方安家了。Mary生气了,骂Andy没有脑子,并让他重新建立猪圈。这回Andy建造了5个猪圈,但是仍然有1头猪没有地方去,然后Andy又建造了7个猪圈,但是还有2头没有地方去。Andy都快疯了。你对这个事情感兴趣起来,你想通过Andy建造猪圈的过程,知道Andy家至少养了多少头猪。 Input输入包含多组测试数据。每组数据第一行包含一个整数n (n <= 10) – A 阅读全文

posted @ 2012-12-05 00:14 forevermemory 阅读(178) 评论(0) 推荐(0)

Shell Pyramid
摘要:DescriptionIn the 17th century, with thunderous noise, dense smoke and blazing fire, battles on the sea were just the same as those in the modern times. But at that time, the cannon ,were extremely simple. It was just like an iron cylinder, with its rearward end sealed and forward end open. There wa 阅读全文

posted @ 2012-12-04 00:24 forevermemory 阅读(231) 评论(0) 推荐(0)

钱币兑换问题
摘要:钱币兑换问题Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3180Accepted Submission(s): 1786Problem Description在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法。Input每行只有一个正整数N,N小于32768。Output对应每个输入,输出兑换方法数。Sample Input293412553Sample Output71883113137761 阅读全文

posted @ 2012-10-28 23:28 forevermemory 阅读(165) 评论(0) 推荐(0)