随笔分类 -  数论

ACM第五乐章--数论
摘要:/*Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901).*/#include<stdio.h>#include<string.h>long long mod = 9901;long long exp(long long a,long long b,long long c){ long long ans = 1; while( 阅读全文

posted @ 2012-10-30 09:18 aigoruan 阅读(184) 评论(0) 推荐(0)

HNCPC D题
摘要:大数开方View Code #include<iostream>#include<string>#include<string.h>#include<cstdlib>#include<stdio.h>#include<algorithm>#include<cmath>using namespace std;#define MAXN 2000int big(char s1[],char s2[]){ int len1,len2,i,q; q=0; while(s1[q]=='0') q++; st 阅读全文

posted @ 2012-10-14 20:45 aigoruan 阅读(143) 评论(0) 推荐(0)

ZOJ Monthly, September 2012 BiliBili
摘要:题意:在一个11维空间里,已知12个点的坐标和这12个点到第13个点的距离,求第13个点的坐标。思路:先设第13个点的坐标为(a1,a2,,,,,a11)利用已知可以得出12个11元2次方程。把12个方程都展开成a1^2+a2^2+........a11^2=......然后用第一个方程分别和另外的11个等价,便可得到11个11元1次方程。这样剩下就是解方程组了。View Code #include<stdio.h>#include<string.h>#include<math.h>#define MAXN 15#define eps 1e-13double 阅读全文

posted @ 2012-10-01 21:42 aigoruan 阅读(237) 评论(0) 推荐(0)

2012 2012 ACM/ICPC Asia Regional Jinhua Online Sum
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4407思路:问题转化:给定n,p,求n内和p互质的数的和。剩下的暴力。关键代码是队友写的:View Code #include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>#include<map>#include<stdio.h>#include<string.h>#include<stdlib.h>#include<algo 阅读全文

posted @ 2012-09-22 18:36 aigoruan 阅读(244) 评论(0) 推荐(0)

uva 10275 Guess the Number!
摘要:Guess the Number!http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1216题意:给一个大数,问能否写成n^n。如果能,输出n,否则输出-1。思路:除了1^1=1,2^2=4特殊外,其它数n^n所得到的数具有唯一的位数。这样可通过所给的大数的位数确定是哪个数,然后求n^n和所给的大数比较就行了。n^n用快速幂来弄,然后用傅立叶大数相乘模板卡过去了,这个方法可能不是正解。View Code #include<st 阅读全文

posted @ 2012-08-26 20:51 aigoruan 阅读(244) 评论(0) 推荐(0)

hdu 2807
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2807题意:给n个m*m的矩阵,如果A*B=C,说明A到C有长度1的有向边。现要求任意点间的最短路。思路:读完题会感觉是一个暴力的算法。但时间达到80^5,感觉过不了,随后看人家的解题报告,结果暴力都过了,数据有点水吧。但是后来自己写了个暴力,却超时了。人品呀~~~然后问队友,发现有优化的:如果A*B=C,则A*B*D=C*D,D为m*1的矩阵。设d=B*D,则A*B*D=A*d;同样设dd=A*d,cc=C*D;最后比较dd是否等cc就行了。当然,D最好多取几个,以保证答案正确。View Code #inc 阅读全文

posted @ 2012-08-10 18:35 aigoruan 阅读(172) 评论(0) 推荐(0)

导航