数学
lj_acm
这个作者很懒,什么都没留下…
展开
-
poj 1183
在网上看的解题报告,推到了一会,终于想明白了这个过程,先写出c关于b的关系式,通过枚举b看是否符合c是整数的条件,然后确定界的问题,根据式子首先可确定b>a, 因为b和c在关系式中具有对称性,那么可让b永远都 得到的第一个满足的,f就是最小,注意a*a比较大,要用unsigned long来定义a #include #include using namespace std; int ma原创 2012-11-08 21:43:33 · 515 阅读 · 0 评论 -
hdu 3714
三分法求下凸函数的最小值,可知,max(下凸函数,下凸函数)得到的函数认为下凸函数 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=10000+10; 6 double a[maxn],b[maxn],c[maxn]; 7 int n; 8 double so原创 2013-08-06 17:34:29 · 844 阅读 · 0 评论 -
poj 1026
置换循环的应用。起初的状态为1,2,3......n,变换一次变为题目给出的序列,找出每个循环,可知每次变换每个字符的位置都是由本循环中的位置循环移动而来,通过模运算可得出每个字符在变换了多次之后,应该在的位置。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=200+1原创 2013-08-06 17:34:06 · 778 阅读 · 0 评论 -
poj 2154
polya定理+欧拉函数优化,1641ms水过,具体参考的解题报告:http://www.cnblogs.com/staginner/archive/2012/03/08/2385052.html 1 #include 2 #include 3 using namespace std; 4 typedef long long LL; 5原创 2013-08-06 17:34:08 · 712 阅读 · 0 评论 -
poj 3128
置换的应用。若一个置换B中所有的元素个数为偶数的循环节和它元素相等的循环节的个数为偶数个,就存在置换A使得A^2=B 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=30; 6 char s[maxn]; 7 int vis[maxn],cou[maxn];原创 2013-08-06 17:34:13 · 897 阅读 · 0 评论 -
poj 1286
polya定理的基础题目。置换群中有两种情况。#include #include #define LL long long using namespace std; const int maxn=30; LL pow[maxn]; int gcd(int a,int b) { return b==0?a:gcd(b,a%b); } int main() { pow[1]=3;原创 2013-05-05 22:11:30 · 793 阅读 · 0 评论 -
poj 1012
约瑟夫问题,感谢这篇博客,让我想了两天之后,看了n篇解题报告都没想懂的情况下,彻底搞懂了这个问题 blog.csdn.net/tsaid/article/details/7313382 #include #include using namespace std; int f[15]; int solve(int n,int m) { int i,loc=0; for原创 2013-04-27 15:07:48 · 689 阅读 · 0 评论 -
poj 3252
组合数学,对于长度为l的二进制数n,先求出长度小于l的满足意义的数,这里长度为l的数,都是指二进制以1开头的长度为为l的数,讨论以0开头的数在这种方法下没什么意义,因为每个数都可确定的知道其长度,并且是以1开头的,也就是说这样的分类可以包括所有的数并且没有重叠。然后再求长度为为l的小于n的满足要求的书。然后再检查n看他本身是否满足条件。这样就求出了1~n中满足条件的数的个数,还有c++提交除以2用原创 2013-04-23 14:26:19 · 882 阅读 · 0 评论 -
hdu 3123
数论 模 #include #include #include using namespace std; const int maxn=110; char n[maxn],m[maxn]; int int_m; int len1,len2; int judge() { if(len1>len2) return 1; char tn[maxn],tm[maxn]; int i,j;原创 2013-02-03 15:39:48 · 384 阅读 · 0 评论 -
2010湖南省赛C题(数字整除)
大整数取模,脑袋怎么就不开窍呢 //我太愚蠢啦 #include #include #include using namespace std; char s[200]; int main() { while(gets(s)) { if(strcmp(s,"0")==0) break; int i; int len=strlen(s); int ou=0; for(i原创 2013-01-04 15:35:16 · 517 阅读 · 0 评论 -
zoj 3622
素数唯一分解定理 #include #include using namespace std; long long f[15][110]; int t[110]; int main() { long long m,n; for(int i=1;i<=10;i++) { t[i]=0; for(int j=0;j<=i;j++) { for(int k=0;k<=i;原创 2012-12-23 11:47:14 · 482 阅读 · 0 评论 -
poj 1061
哎,折腾了一中午,终于ac拉。考察的是欧拉算法的扩展。我在此题中,思考的时间最长的部分就是通过扩展了欧拉算法得到了解后,如何得到最小的正整数解。对于这个小问题,我却百思不得其解。然后在网上找了解题报告后,才有了思路,就是先求出解系,然后通过这个解系的式子得到最小的整数解 #include #include using namespace std; void gcd(long long a,l原创 2012-11-13 15:09:50 · 400 阅读 · 0 评论 -
poj 1152
数据量不大,可以直接枚举。首先确定所需要的最小进制,然后从此处向62进行枚举。然后就是关于求摸的问题。不可能把整个数先求出来。因为数很大,根本存不下。根据求摸公式可得结果a1a2a3a4...a(s)%(n-1)=(a1+a2+...a(s)))%(n-1) #include #include using namespace std; char s[40000]; int get(char原创 2012-11-12 16:43:18 · 495 阅读 · 0 评论 -
poj 1730
数论唯一分解定理的应用,要注意负数的情况,想明白这个过程用了两个小时,后来因为一个while写成了if有调试了俩小时,为什么还是这么菜 数论唯一分解定理的应用,要注意负数的情况,想明白这个过程用了两个小时,后来因为一个while写成了if有调试了俩小时,为什么还是这么菜 #include #include using namespace std; int gcd(int a,int b) {原创 2012-11-11 18:37:45 · 523 阅读 · 0 评论 -
poj 2262
很基础的一道数学题,不过感觉跑的太慢啊,422ms #include #include using namespace std; const int maxn=1000001; int vis[maxn],p[maxn]; int t; void prime() { t=0; int i,j; int n=(int)sqrt(maxn-1); for(i=2;i<=n;i++) {原创 2012-11-09 17:11:47 · 433 阅读 · 0 评论 -
BNU 16225
#include #include #include #include #include #include #include #include #define LL long long #define myabs(x) ((x)>0?(x):(-(x))) using namespace std; const int inf=0x3f3f3f3f; int main() { LL原创 2013-08-27 01:02:32 · 658 阅读 · 0 评论