题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5170 bc(中文):http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=567&pid=1001 题解: 先用java大数幂写的,t了 import java.util.*; import java.math.*; public class Main { public static void main(St…
题意: 给a,b,c,d. 比较a^b和c^d的大小 思路: 比较log(a^b)和log(c^d)的大小 代码: int a,b,c,d; int main(){ while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF){ double x1 = b*log((double)a); double x2 = d*log((double)c); if(fabs(x1-x2)<eps){ puts("=")…
数学题,a的b次方和c的d次方都很大,直接判断是做不出来的. 如果我们能找到一个函数F(x)是单调的,而F(X)的值又比较好算,那么可以通过比较F(X)的大小来判断自变量的大小. 令F(X)=log(X),a的b次方和c的d次方当做自变量. 那么接下来只要判断log(a的b次方)和log(c的d次方)的大小就可以判断a的b次方和c的d次方的大小了. 而log(a的b次方)=b*log(a),log(c的d次方)=d*log(c),很容易计算. 判断相等的时候注意一下精度问题. #include<…
主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5055 Problem Description Recently, Bob has been thinking about a math problem. There are N Digits, each digit is between 0 and 9. You need to use this N Digits to constitute an Integer. This Integer need…
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=1757 A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6621    Accepted Submission(s): 4071 Problem Description Lele now is thin…
A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2441    Accepted Submission(s): 1415 Problem Description Lele now is thinking about a simple function f(x). If x < 10 f(x) =…
Jam's math problem Problem Description Jam has a math problem. He just learned factorization.He is trying to factorize ax^2+bx+c into the form of pqx^2+(qk+mp)x+km=(px+k)(qx+m).He could only solve the problem in which p,q,m,k are positive numbers.Ple…
题目 A Simple Math Problem 解析 矩阵快速幂模板题 构造矩阵 \[\begin{bmatrix}a_0&a_1&a_2&a_3&a_4&a_5&a_6&a_7&a_8&a_9\\ 1&0&0&0&0&0&0&0&0&0\\ 0&1&0&0&0&0&0&0&0&0\\ 0&…
A Simple Math Problem [题目链接]A Simple Math Problem [题目类型]矩阵快速幂 &题解: 这是一个模板题,也算是入门了吧. 推荐一个博客:点这里 跟着这个刷,应该就可以了 &代码: #include <cstdio> #include <iostream> #include <set> #include <cmath> #include <cstring> #include <al…
A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1697    Accepted Submission(s): 959 Problem Description Lele now is thinking about a simple function f(x). If x < 10 f(x) =…
A Simple Math Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1645    Accepted Submission(s): 468 Problem Description Given two positive integers a and b,find suitable X and Y to meet th…
A. Math Problem Your math teacher gave you the following problem: There are n segments on the x-axis, [l1;r1],[l2;r2],-,[ln;rn]. The segment [l;r] includes the bounds, i.e. it is a set of such x that l≤x≤r. The length of the segment [l;r] is equal to…
A serious math problem Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description Xiao Jun likes math and he has a serious math question for you to finish. Define \(F[x]\) to the \(xor\) sum of all digits of…
题目地址:HDU 1757 最终会构造矩阵了.事实上也不难,仅仅怪自己笨..= =! f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + -- + a9 * f(x-10) 构造的矩阵是:(我代码中构造的矩阵跟这个正好是上下颠倒过来了) |0 1 0 ......... 0|    |f0|   |f1 | |0 0 1 0 ...... 0|    |f1|   |f2 | |...................1| *  |..| = |...…
The sum problem Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 31453    Accepted Submission(s): 9414 Problem Description Given a sequence 1,2,3,......N, your job is to calculate all the possib…
Problem Description Given two positive integers a and b,find suitable X and Y to meet the conditions:                                                        X+Y=a                                              Least Common Multiple (X, Y) =b   InputInp…
http://acm.hdu.edu.cn/showproblem.php?pid=5055 题目大意: 给你N位数,每位数是0~9之间.你把这N位数构成一个整数. 要求: 1.必须是奇数 2.整数的前面没有0 3.找到一个最大的整数 如果满足1.2.3条件,就输出这个数,不满足就输出-1. 给个例子 3 1 0 0 这个构成的奇数是001,这个数前面有0,应该输出-1 解题思路: 对给的N个数升序排序. 然后最小的开始找,找到一个奇数,然后把它放在最左边. 然后判断这个数是否,满足要求.满足要…
题目链接 题意 :给你m和k, 让你求f(k)%m.如果k<10,f(k) = k,否则 f(k) = a0 * f(k-1) + a1 * f(k-2) + a2 * f(k-3) + …… + a9 * f(k-10);思路 :先具体介绍一下矩阵快速幂吧,刚好刚刚整理了网上的资料.可以先了解一下这个是干嘛的,怎么用. 这个怎么弄出来的我就不说了,直接看链接吧,这实在不是我强项,点这儿,这儿也行 //HDU 1757 #include <iostream> #include <s…
方法一:由十字相乘相关理论我们能知道,如果要有p,k,q,m,那么首先要有解,所以b*b-4*a*c要>0,然而因为p,k,q,m是正整数,所以代表x1,x2都是有理数,有理数是什么鬼呢?就是解不带根号,我们知道有求根公式,其中2*a,-b都保证是自然数了,如果根号下b*b-4*a*c也保证是有理数我们就就能保证解是自然数,那么如何保证根号下b*b-4*a*c是有理数呢?那么b*b-4*a*c就是平方数 #pragma comment(linker, "/STACK:1024000000,…
Problem Description Lele now is thinking about a simple function f(x). If x < f(x) = x. If x >= f(x) = a0 * f(x-) + a1 * f(x-) + a2 * f(x-) + …… + a9 * f(x-); And ai(<=i<=) can only be or . Now, I will give a0 ~ a9 and two positive integers k…
题意:当x < 10时, f(x) = x: 当x >= 10 时,f(x) = a0 * f(x-1) + a1 * f(x-2) +  + a2 * f(x-3) + …… + a9 * f(x-10): ai(0<=i<=9) 只能是0或者1 ,给出a0 ~ a9,k和m,计算f(k)%m(k<2*10^9 , m < 10^5). 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1757 ——>>构造矩阵…
题意:一种彩票共同拥有 N 个号码,每注包括 M 个号码,假设开出来的 M 个号码中与自己买的注有 R 个以上的同样号码,则中二等奖,问要保证中二等奖至少要买多少注(1<=R<=M<=N<=8). 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4979 -->>覆盖问题,yy可知是可反复覆盖问题,于是,DLX 上场.. N个 选 R 个,共同拥有 C[N][R] 种选法,每种选法须要被覆盖,相应于 DLX 中的列.. N个…
A: HDU5170 这题让比较a^b与c^d的大小.1<=a,b,c,d<=1000. 显然这题没法直接做,要利用对数来求,但是在math库中有关的对数函数返回的都是浮点数,所以这又要涉及到eps问题. 其它就没有什么需要注意的了,我用的是log()函数,当然还可以用log10().....,原理不变. #include <iostream> #include <algorithm> #include <math.h> #include <map&g…
http://acm.hdu.edu.cn/showproblem.php?pid=5974 遇到数学题真的跪.. 题目要求 X + Y = a lcm(X, Y) = b 设c = gcd(x, y); 那么可以表达出x和y了,就是x = i * c; y = j * c; 其中i和j是互质的. 所以lcm(x, y) = i * j * c = b 那么就得到两个方程了. i * c + j * c = a; i * j * c = b; 但是有一个c,三个未知数. 因为i和j互质,所以(i…
题目描述: Given two positive integers a and b,find suitable X and Y to meet the conditions: X+Y=a Least Common Multiple (X, Y) =b Input Input includes multiple sets of test data.Each test data occupies one line,including two positive integers a(1≤a≤2*10^…
d. Jam有道数学题想向你请教一下,他刚刚学会因式分解比如说,x^2+6x+5=(x+1)(x+5) 就好像形如 ax^2+bx+c => pqx^2+(qk+mp)x+km=(px+k)(qx+m) 但是他很蠢,他只会做p,q,m,kp,q,m,k为正整数的题目 请你帮助他,问可不可以分解 题意就是问一个一元二次方程能不能进行十字相乘的分解? s. 官方题解:第一道题比较简单,可以说是简单的模拟题,我们考虑到a,b,c都是10^9​​的,所以我们决定要把时间复杂度降下来, 对于每一个数,因为…
Problem Description Given two positive integers a and b,find suitable X and Y to meet the conditions: X+Y=a Least Common Multiple (X, Y) =b   Input Input includes multiple sets of test data.Each test data occupies one line,including two positive inte…
Description Lele now is thinking about a simple function f(x). If x < 10 f(x) = x. If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10); And ai(0<=i<=9) can only be 0 or 1 . Now, I will give a0 ~ a9 and two positive in…
题目 也是和LightOJ 1096 和LightOJ 1065 差不多的简单题目. #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int num,mod; struct matrix { ][]; }; matrix multiply(matrix x,matrix y)//矩阵乘法 { matrix temp; ;i<num;i++) { ;j<…
先把各个数字又大到小排列,如果没有前导零并且为奇数,则直接输出.如果有前导零,则输出-1.此外,如果尾数为偶数,则从后向前找到第一个奇数,并把其后面的数一次向前移动,并把该奇数放到尾部. 值得注意的是当输入为960时,通过这种方法会得到具有前导零的数字.因此最后需要判断进行移动后,首位是否为零. 代码如下: #define MAXN 101 #include <stdlib.h> #include <iostream> #include <cstdio> #includ…