ACM_数学专项系列
acceptedwwh
当代大学生,阳光开朗,乐于交往和求知!
展开
-
分解质因数(算术基本定理)
#include #include #include using namespace std;int isprime(int a){ int i; for(i = 2; i if(a%i == 0){ return 0; } } return 1;}void primefactor(int n原创 2012-09-22 22:20:23 · 1240 阅读 · 0 评论 -
UVA11401(Triangle Counting)
Problem GTriangle CountingInput: StandardInputOutput: StandardOutput You are given n rods of length 1, 2…, n. You have topick any 3 of them & build a triangle. How many distinct triangles原创 2013-04-22 18:09:03 · 1486 阅读 · 0 评论 -
UVA11538(Chess Queen )
Problem AChess Queen Input: Standard InputOutput: StandardOutput You probably know how the game ofchess is played and how chess queen operates. Two chess queens are in attackingposition when t原创 2013-04-22 16:13:23 · 1192 阅读 · 0 评论 -
hdu1593(find a way to escape)
find a way to escape Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)原创 2013-04-29 20:42:28 · 1301 阅读 · 0 评论 -
TOJ1502Find All M^N Please
Find All M^N Please Time Limit(Common/Java):1000MS/10000MS Memory Limit:65536KByteTotal Submit: 37 Accepted: 15DescriptionRecently, Joey has special interest in the pos转载 2013-09-18 20:18:02 · 1032 阅读 · 0 评论 -
POJ2249 Binomial Showdown
组合数原创 2014-03-11 11:51:44 · 896 阅读 · 0 评论 -
POJ2661 Factstone Benchmark
基础题目原创 2014-03-11 10:21:42 · 1002 阅读 · 0 评论 -
POJ1306 Combinations
组合数原创 2014-03-11 11:57:02 · 942 阅读 · 0 评论 -
HDU1019 Least Common Multiple
HDU1019原创 2014-04-29 20:53:58 · 963 阅读 · 0 评论 -
HDU2138 How many prime numbers
POJ2138 素数判定原创 2014-04-28 16:42:12 · 1166 阅读 · 0 评论 -
大数模余
题目描述: A lot of people have played fortune Test(or called RP Test) before. Let ’ s create a new Test below.Suppose the worth of a=1, b=4,c=9 … and z=26^2. Then abc can describe as 149,and abd原创 2013-03-16 21:13:25 · 1904 阅读 · 0 评论 -
poj1284Primitive Roots(欧拉函数)
#include #include #include using namespace std;//Accepted 164K 0MSint work(int n) { int rea = n; for(int i = 2; i*i<=n; i++) { if(n%i == 0) { rea = rea - rea/i;原创 2013-02-23 17:20:32 · 993 阅读 · 0 评论 -
POJ2407Relatives(欧拉函数入门题目)
#include #include #include using namespace std;//Accepted 164K 0MS C++ 472Bint work(int n) { int rea = n; for(int i = 2; i*i<=n; i++) { if(n%i == 0) { rea = rea - rea/原创 2013-02-23 17:05:17 · 1347 阅读 · 0 评论 -
打印素数
#include using namespace std;#define N 1000int f[N];int main(){ for(int i = 2; i*i if( 0 == f[i]){ for(int j = i + i; j if(1 != f[j]){原创 2012-09-22 21:53:46 · 785 阅读 · 0 评论 -
十进制转十六
#include #include #define M 1000using namespace std;int k = 0;char a[20] = {'0','1','2','3','4','5','6','7','8','9','A', 'B','C','D','E','F'};int change(int num, char *p){ int m原创 2012-10-17 13:14:55 · 903 阅读 · 0 评论 -
递归法求幂
#include #include #include using namespace std;int myPow(int m, int n){ int temp; if(0 == n){ return 1; } if(1 == n){ return m; } if(n%2 == 0){ temp =原创 2012-09-22 22:34:19 · 1541 阅读 · 0 评论 -
扩展欧几里得(递推实现)
#include #include #define maxn 1000#define INF 0xfffffffusing namespace std;int m = 0, n = 0;int gcd = 0;int x[maxn], y[maxn], q[maxn];void extend_gcd(){ x[1] = 1; y[1] = -q[0]; x原创 2012-10-23 15:00:12 · 1617 阅读 · 3 评论 -
hdu1021
#include#includeint main(){ int n; while(scanf("%d",&n)!=EOF){ if(n%4==2) printf("yes\n"); else printf("no\n"); } return 0;}/***********************************原创 2012-10-24 13:49:25 · 934 阅读 · 1 评论 -
hdu1021(Fibonacci Again)
#include #include using namespace std;int a[1000010];int main(){ a[0] = 7%3; a[1] = 11%3; int t; for(int i = 2; i < 1000000; i++){ t = a[i-1]%3 + a[i-2]%3; a[i] = t%3原创 2012-10-24 13:26:33 · 850 阅读 · 0 评论 -
hdu1719(Friend)
#include #include #include using namespace std;int main(){ int n; while(scanf("%d", &n) != EOF) { if(n == 0) { printf("NO!\n"); continue; } ///n = 0 let me WA! int tmp原创 2013-02-18 21:43:39 · 956 阅读 · 1 评论 -
POJ1833(字典序的排序算法)
#include #include #include #include using namespace std;//Accepted 168K 454MS C++bool gen_perm(int *a, int n) { if(n == 1) { return false;} int i, j, k, t; for(j = n-2; j >= 0; j--)原创 2013-02-21 17:44:28 · 1384 阅读 · 0 评论 -
幂取模
#include #include #include using namespace std;int pow_mod(int a, int n, int m) { //时间复杂度:O(logn) if(n == 1) { return a%m; } int x = pow_mod(a, n/2, m); long long ans = (long long)x *原创 2013-02-24 15:11:26 · 934 阅读 · 0 评论 -
HDU5211Mutiple
HDU5211Mutiple原创 2015-04-27 15:52:13 · 835 阅读 · 0 评论