随笔分类 -  其它oj

移位运算
摘要:XiaoA is a lovely boy who likes designing some digital product.One day, he met XiaoB who is XiaoA's little girl friend and told her that his new product had came out.It's a calculator which can do "add"(+) opeartion and "sub"(-) operation between nonnegative numbers.Actually, XiaoA's calculator is v 阅读全文
posted @ 2011-01-01 13:14 role 阅读(206) 评论(0) 推荐(0)
LUCK——组合数学
摘要:Description As we all know, Hongshu was awarded the title “The Outstanding Student of UESTC”(成电杰出学生). Surprisingly, he found that another outstanding student shares the same birthday with him. However, after carefully thinking, he realised that it is not a “small probability event”. Now, he wants to 阅读全文
posted @ 2011-01-01 10:15 role 阅读(170) 评论(0) 推荐(0)
I'm Hungry ----dp
摘要:I'm HungryDescription The canteen in UESTC is a crazy place. Every day, thousands of people are rushing to the canteen after class. But there is a long line before the each window always, which makes people disappoint and angry. Today, LY will meet a very important person, so he wants to finish the 阅读全文
posted @ 2011-01-01 09:40 role 阅读(229) 评论(0) 推荐(0)
质因子的求法
摘要:寻找质因子 1:质因子除了2都是偶数,可以先求出2的因子个数,然后再奇数范围内找满足整除的.(不知道为啥,效率有时不高) 2:从两边判断: 如果在=m/2或是=sqrt(m)范围内没有找到能整除的则i是素因子。如果im/2则m也是素数,m/=i; 代码如下: scanf("%d",&n); while(1) { for(i=2;i=sqrt(n);i++) if(n%i==0) {is_p[i]++;break;}//is_p存素因子i,的个数 if(isqrt(n)) {is_p[n]++;break;} n/=i; } 应用:题目如下: Description 对于任意一个整数n 阅读全文
posted @ 2010-12-31 18:26 role 阅读(5078) 评论(0) 推荐(0)