
joj acm_数学问题
文章平均质量分 86
kongming_acm
kongming_acm
展开
-
joj 2344: Dissolution of Integer 将N分解成乘积形式 共有多少种解法
As you known,a positive integer can be written to a form of products of several positive integers(N = x1 * x2 * x3 *.....* xm (xi!=1 (1<=i<=原创 2011-10-04 12:05:05 · 702 阅读 · 0 评论 -
joj 1700 棋盘上最多放多少个马 车 王 后
<br />#include<iostream><br />#include<cstdio><br />#include<algorithm><br />using namespace std;<br />int main()<br />{<br /> int x,y;char ch;<br /> int ci;cin>>ci;<br /> while(ci--)<br /> {<br /> cin>>ch>>x>>y;<br /> int r;<br /原创 2010-07-23 23:29:00 · 499 阅读 · 0 评论 -
joj1445 棋盘上最多放多少马
<br />#include<iostream><br />#include<cstdio><br />#include<algorithm><br />using namespace std;<br />int main()<br />{<br /> //freopen("aaa.txt","r",stdin);<br /> //freopen("1.txt","w",stdout);<br /> int x,y;<br /> while(cin>>x>>y)<br /> {原创 2010-07-23 23:29:00 · 969 阅读 · 0 评论 -
2288: Game 将n个数排列成一个最大的数 通过sort实现
#include#include#includeusing namespace std;bool cmp(string a,string b){ string c=a+b; string d=b+a; return c>d;} int main(){ int n; string a[60]; while(cin>>n&&n) { for(int i=0;i>a[i]; sort(a,a+n,cmp); for(int原创 2010-07-22 13:27:00 · 559 阅读 · 0 评论 -
1063: A Funny Game 博弈问题
<br />1063: A Funny GameResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K627219Standard<br />1st JOJ Cup Online VContest Warmup Problem<br />Tom and Jack are on the train. The journey is too dull so much so that both of them are eager to find a way原创 2010-07-21 15:19:00 · 685 阅读 · 0 评论 -
2252: Pick Balls
<br />2252: Pick BallsResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K373158StandardSherry is an excellent student of Jilin University. Today her teacher gives her a bag which is filled with M balls. She wants to pick all of them out. To make it i原创 2010-07-21 13:58:00 · 533 阅读 · 0 评论 -
1044: Parencodings
<br /> 1044: ParencodingsResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K613302Standard<br />Let S = s1 s2 … s2n be a well-formed string of parentheses. S can be encoded in two different ways:By an integer sequence P = p1 p2 … pn where pi is the n原创 2010-07-21 11:55:00 · 351 阅读 · 0 评论 -
1491: Biorhythms 剩余定理
<br />1491: BiorhythmsResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K354147Standard<br />Some 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原创 2010-07-21 16:20:00 · 346 阅读 · 0 评论 -
2236: Balance and Poise
<br />2236: Balance and Poise<br />ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE5s8192K300133Standard<br />工匠大师Hill打造出一个精致的天平, 对他的徒弟Oren说:“你帮我做一些砝码配套,为了方便携带,砝码数目要尽量少”。 Oren:“好。我将按照2进制的规则打造,也就是1,2,4,8,16等等,这样在称量同等重量下使用的砝码数量最少,只使用7个砝码就可以称量1-127的重量。” <原创 2010-07-21 10:55:00 · 517 阅读 · 0 评论 -
2428: Super Prime 求超级素数
<br />2428: Super PrimeResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K31388Standard<br />In these days, skywind had thought a series of new problem. But he must keep these problem for the coming important contests such as "JiLin Provincial Colleg原创 2010-07-17 21:54:00 · 1076 阅读 · 0 评论 -
1926: Factovisors N的阶乘的质因子个数
<br />1926: Factovisors<br />ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K659122StandardThe factorial function, n! is defined thus for n a non-negative integer: 0! = 1 n! = n * (n-1)! (n > 0)We say that a divides b if there exists a原创 2010-07-17 23:34:00 · 840 阅读 · 0 评论 -
忘了是joj第几题了 剩余定理
<br />#include<stdio.h> <br />int mod(int c[],int b[],int n) <br />{ <br /> int all_multy=1,sum=0; <br /> int i,j,x[5]; <br /> for(i=0;i<n;i++) <br /> all_multy*=c[i]; <br /> for(i=0;i<n;i++) <br /> x[i]=all_multy/原创 2010-07-10 22:05:00 · 454 阅读 · 0 评论 -
1716: Divisors 辅助筛选 求因子
<br />1716: DivisorsResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K317113Standard<br />Mathematicians love all sorts of odd properties of numbers. For instance, they consider 945 to be an interesting number, since it is the first odd number for w原创 2010-07-10 22:04:00 · 430 阅读 · 0 评论 -
2676: Problem B
<br />#include<stdio.h><br />int main()<br />{<br /> double x1,x2,x3,y1,y2,y3;<br /> while(scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3)==6)<br /> {<br /> double x4=(x1+x2)/2,y4=(y1+y2)/2;<br /> double x5=(x1+x3)/2,y5=(y1+y3)/2原创 2010-07-10 22:00:00 · 324 阅读 · 0 评论 -
2661: 数字游戏 拓展欧几里得定理
<br />2661: 数字游戏ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE2s32768K35740Standard<br />Raven很喜欢数字游戏,今天他看到两个数,就想能否通过简单的加减,使最终答案等于1。而他又比较厌烦计算,所以他还想知道最少经过多少步加减才能得到1。好吧,我想,是你开动脑筋的时候了。 (注意:至少需要做一步加减法) Input<br />输入包含多组数据。第一行有一个正整数T,表明输入数据的组数。接下来T行,每行有2个非负原创 2010-07-10 22:00:00 · 686 阅读 · 0 评论 -
joj 2141
<br />#include<iostream><br />#include<cstdio><br />#include<cstring><br />using namespace std;<br />int a[10005],pos[10005];//pos::important 记录位置 <br />int main()<br />{<br /> int n;char ch;<br /> while(cin>>n&&n)<br /> {<br /> cin>>ch;<b原创 2010-07-23 23:31:00 · 385 阅读 · 0 评论 -
1928 Prime Distance 素数筛选法 ,筛选一段区间的素数
1928: Prime DistanceResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K4919StandardThe branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number theoreticians for thousands o原创 2010-08-03 09:54:00 · 617 阅读 · 0 评论 -
joj 2653 不同的数 从2*n中找出不相同的两个数
2653: 不同的数ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s65536K38778Standard原来有n对数字原创 2011-08-25 20:58:57 · 748 阅读 · 0 评论 -
joj 2732: Cow XOR 求最大异或段
Farmer John is stuck with another problem while feeding his cows. All of his N (1 ≤ N ≤ 100,000) cows (numbered 1..N) are lined up in front原创 2011-08-16 22:40:17 · 1043 阅读 · 0 评论 -
2519: Find the longest section 位运算+前缀和
<br />2519: Find the longest sectionResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE1s8192K13329Standard<br />There are n strings with the原创 2011-04-18 20:16:00 · 666 阅读 · 0 评论 -
joj 2736: 二叉树计数 卡特兰数取模 1<=n<=10^9,1<=m<=32768
给出n,k.求含有n个节点的不同二叉树数目%k InputMULTI TEST CASE!!每行两个整数n,k(1一行二叉树的数目%k Sample Input3 100Sample Output5//师哥模板#include #include #include #inclu原创 2011-04-25 11:43:00 · 1734 阅读 · 0 评论 -
Sum 判断数组中时候有两个数的和等于一个定值 (数组很大) O(n)
SumTime Limit: 9000 MS Memory Limit: 65536 K SumMr. Jojer is given n numbers and an extra integer x, he wants to know whether the原创 2010-09-15 21:11:00 · 931 阅读 · 0 评论 -
2306: Marriage 归并排序求逆序数
<br /> 2306: MarriageResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K50373Standard<br />Now, a lot of persons holding their marriages together are in fashion. One day, a lot of people hold their marriages together. They are all happy, so they want原创 2011-04-18 20:39:00 · 458 阅读 · 0 评论 -
joj 2437: The grabber 等周定理变形 一直两端点和周长,求最大面积
<br /> 2437: The grabberResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K26662Standard<br />When you buy land at the vast grassland, the area depends on your equestrianism. The farmer will give you a horse after received a fixed amount of money. Yo原创 2011-04-08 20:08:00 · 586 阅读 · 0 评论 -
2386: Find the Coin 一个天平,一堆石子中只有一个比较重,用最少的次数找出
<br /> 2386: Find the CoinResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K213104Standard<br />One day, Φ has 8 golden coins. He knew one of them is heavier than others. He wants to find out it. Then he wants to borrow X’s scale. But X is so mean.原创 2010-11-11 15:56:00 · 813 阅读 · 0 评论 -
2701: Party 排列组合问题
2701: PartyResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE1s8192K323Standard<br />Go, go, go, it's party time !!! A great many of guests are invited. Guests are numbered from 1 to N. To make the party more joyful, every 3 guests, who are friends to each原创 2010-11-01 13:09:00 · 818 阅读 · 0 评论 -
2576: The K-th minimum number 高级二分 矩阵c[i][j]=a[i]*b[j] 求c数组中第k小数
<br />2576: The K-th minimum numberResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE5s32768K44138Standard<br />This problem is finding the K-th minimum number of a Matrix. The matrix is defined as below:1. The matrix C has N rows and M columns. 2. C[i][j]原创 2010-09-10 20:16:00 · 1478 阅读 · 0 评论 -
2693: I 矩阵连乘
#include#include#includeusing namespace std;const int maxn=101;int mod=1000;class Matrix{ int n,m;//矩阵的row and colum int num[maxn][maxn];//从1开始 public: Matrix(){memset(num,0,sizeof(num));} Matrix(const Matrix &a) {n=a.n;m=a.m; memcpy原创 2010-08-19 22:39:00 · 612 阅读 · 1 评论 -
2174: Accumulator 计算从0加到n共有多少位发生过变化
<br />2174: AccumulatorResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K324109StandardAccumulator can be used to count the number of the objects. Initially, the value of accumulator is set to zero. After each objected is counted, the value of accum原创 2010-08-13 23:20:00 · 556 阅读 · 0 评论 -
2606: 星空 矩阵模板 二分矩阵乘法
2606: 星空ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE1s65536K17918Standardsky是一个喜欢浪漫的人,对浩淼的星空总是有无穷的幻想,每天晚上他都会在独院里听着music,欣赏着银河的璀璨,可是随着时间的的延续,他发现天空中的每颗星的亮度竟都是不同的。而且每一秒都在不停的闪烁,亮度总是不同,真是神奇的自然,他看到天上的n颗星辰,他记得爷爷曾经告诉他星星在第s初时的亮度分别为l[1][0]~l[n][0],每一秒,在同一时刻的同原创 2010-08-09 14:34:00 · 914 阅读 · 2 评论 -
1004: Octal Fractions 利用秦九韶定理进行小数的进制转换
<br />1004: Octal FractionsResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K3535790Standard<br />Fractions in octal (base 8) notation can be expressed exactly in decimal notation. For example, 0.75 in octal is 0.963125 (7/8 + 5/64) in decimal. All原创 2010-08-10 22:45:00 · 701 阅读 · 0 评论 -
2475: Matrix Tops
<br /> 2475: Matrix TopsResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE5s131072K67978Standard<br />This is an interesting problem about finding the first Z minimum numbers of a Matrix. The matrix is defined as below: <br /> The matrix C has N rows and M原创 2010-07-10 21:56:00 · 347 阅读 · 0 评论 -
2429: Difference of Square Root
<br />2429: Difference of Square RootResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K1161147Standard<br />At the previous problem , the difference of square is asked. This time, the square root is appeared.<br />Find minimal integer x that satifie原创 2010-07-10 21:55:00 · 450 阅读 · 0 评论 -
2049: Ackermann's Function
<br /> 2049: Ackermann's FunctionResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K928273Standard<br />In this easy problem, you are to write a program to calculate the Ackermann's Function A:<br />A(0, n) = n+1<br />A(m, 0) = A(m-1, 1)<br />A(m, n)原创 2010-07-10 22:01:00 · 533 阅读 · 0 评论 -
2683: Problem I
<br />#include<iostream><br />using namespace std;<br />int main()<br />{<br /> int n;<br /> while(scanf("%d",&n)==1&&n)<br /> {<br /> int sum2=0,sum3=0;<br /> for(int i=2;i<=n;i++)<br /> {<br /> int t=i;<br />原创 2010-07-10 22:01:00 · 308 阅读 · 0 评论 -
2643: Recurring Decimals
<br />#include<stdio.h><br />const int inf=999999;<br />int gcd (int x,int y)<br />{<br /> if(y==0) return x;<br /> return gcd(y,x%y);<br />}<br />int main()<br />{<br /> int n,i,j;<br /> //freopen("out.txt","w",stdout);<br /> for(n=1;n<inf;原创 2010-07-10 21:59:00 · 486 阅读 · 0 评论 -
2640: More Vertexes, More Area
<br />#include<iostream><br />#include<algorithm><br />using namespace std;<br />int main()<br />{<br /> int n,m,s;<br /> while(scanf("%d%d",&n,&m),n||m)<br /> {<br /> if(n==1||m==1) {printf("0/n");continue;}<br /> if(n%2==1&&m%2==1)<br />原创 2010-07-10 21:58:00 · 341 阅读 · 0 评论 -
2629: 排列与二进制
<br />#include<stdio.h><br />int main()<br />{<br /> int n,m;<br /> while(scanf("%d%d",&n,&m)==2&&n)<br /> {<br /> int i,count=0;<br /> for(i=n-m+1;i<=n;i++)<br /> {<br /> int b=i;<br /> while(b%2==0) <br /> {<br /> b/=2;<br /> count++;<br /原创 2010-07-10 21:58:00 · 385 阅读 · 0 评论 -
2544: Length of Rope
<br /> 2544: Length of RopeResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE1s32768K17458Standard<br />There is a convex polygon whose vertices are all nails. The nails are of radius R. We need a rope to round these nails tightly. You can see an example h原创 2010-07-10 21:57:00 · 394 阅读 · 0 评论 -
2285: Decompose
<br />2285: DecomposeResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K267149StandardGive you an positive integer N(1<=N<=30), you can decompose n to several positive integers: A1, A2, ... Ak. (1<=k<=N) And A1 + A2 + ... + Ak = N. Now i want to know原创 2010-07-10 21:54:00 · 346 阅读 · 0 评论