摘要: 求一个混合数列中 指定区间内第K小的数:View Code 1 #include<stdio.h> 2 3 int num[2010]; 4 5 int query(int L,int R,int K) 6 { 7 if(L == R)return num[L]; 8 int i=L; 9 int j=R;10 int mid=num[(L+R)/2];11 while(i<j)12 {13 while(num[i]<mid)i++;14 while(num[j]>mid)j--;15 if(i<=j)16 ... 阅读全文
posted @ 2012-04-04 20:03 知行执行 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 参考:http://en.wikipedia.org/wiki/Euler%27s_totient_functionView Code 1 #include<stdio.h> 2 3 int main() 4 { 5 int n,i; 6 bool flag; 7 while(scanf("%d",&n) != EOF) 8 { 9 int t=n;10 for(i=2;i<=t;++i)11 {12 flag=0;13 if(t%i==0)14 {15 ... 阅读全文
posted @ 2012-04-04 15:19 知行执行 阅读(181) 评论(0) 推荐(0) 编辑