摘要: Fibonacci/* 用到了斐波那契数列的通项公式。 先看对数的性质,loga(b^c)=c*loga(b),loga(b*c)=loga(b)+loga(c); 假设给出一个数10234432,那么log10(10234432)=log10(1.0234432*10^7)=log10(1.0234432)+7; log10(1.0234432)就是log10(10234432)的小数部分. log10(1.0234432)=0.010063744 10^0.010063744=1.023443198 那么要取几位就很明显了吧~ 先取对数(对10取),然后得到结果的小数部分bit,pow.. 阅读全文
posted @ 2013-04-21 20:26 VeryBigMan 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 最小公倍数#include #include using namespace std; int gcd(int a,int b) { int r; if(a>a>>b) cout #include using namespace std; bool isprime(int n) { for(int i=2;i>n) { while(n--) { cin>>temp; if(isprime(temp)) sum++; } cout #include int biao[1000001]; void fun() { int i,j,k=1; m... 阅读全文
posted @ 2013-04-21 10:30 VeryBigMan 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Moving Tables/*解题思路:这道题最少花多少时间,实际上我们只要考虑哪一段重合度最高, 重合度最高的地方,也就是我们至少要移动的次数了。 因为有400间房间,1-2对应一段走廊,3-4对应一段走廊, 如此我们可以把走廊分成200段,标记为a[1]-a[200], 之后我们根据输进的房间序号,就可以算出要用到哪几段的走廊, 之后给对应的a[n]值加1就好,最后求出a[n]最大值就是移动的次数了。 */ #include #include #include using namespace std; int main() { int T; int pair; int a[201];... 阅读全文
posted @ 2013-04-20 21:10 VeryBigMan 阅读(109) 评论(0) 推荐(0) 编辑
摘要: Elevator#include using namespace std; int main() { int n,temp,last=0,sum,N; while(cin>>n,n!=0) { sum=0; last=0; N=n; while(n--) { cin>>temp; if(temp>last) { sum+=(temp-last)*6; last=temp; } else { sum+=(last-temp)*4; last=temp; } } cout using na... 阅读全文
posted @ 2013-04-20 21:07 VeryBigMan 阅读(84) 评论(0) 推荐(0) 编辑
摘要: A+B for Input-Output Practice (I)#include using namespace std; int main() { int a,b; while(cin>>a>>b) cout using namespace std; int main() { int T; int a,b; cin>>T; while(T--) { cin>>a>>b; cout using namespace std; int main() { int a,b; while(cin>>a>>b,a!=0| 阅读全文
posted @ 2013-04-20 21:03 VeryBigMan 阅读(111) 评论(0) 推荐(0) 编辑