上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 38 下一页
摘要: 题解:基础的树状数组区间修改,单点查询。#include #include int c[100005],a,b,n;int modify(int x,int num){while(x0)s+=c[x],x-=x&-x;return s;} int main(){ while(~scanf("%... 阅读全文
posted @ 2014-09-01 18:13 forever97 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 题解:找规律……#include int main(){ int n; while(~scanf("%d",&n)){ if((n-2)%4!=0)puts("no"); else puts("yes"); }return 0;} 阅读全文
posted @ 2014-08-30 08:02 forever97 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 题解:求n个数的最小公倍数,一个一个算就可以了,需要注意的是LCM先除GCD再乘,因为先乘有可能会超范围,1WA的代价。#include int T,n,a,b;int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}int main(){ ... 阅读全文
posted @ 2014-08-30 07:42 forever97 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 题解:直接模拟#include int main(){ puts("n e");puts("- -----------");puts("0 1"); double ans=1.0,f=1.0; for(int i=1;i<=9;i++){ if(i==1)... 阅读全文
posted @ 2014-08-29 17:40 forever97 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 题解:简单模拟#include #include using namespace std;int main(){ int n,m,num,cnt,max,i; while(~scanf("%d %d",&m,&n)){ printf("%d %d ",m,n... 阅读全文
posted @ 2014-08-29 17:29 forever97 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 题解:枚举即可……#include int main(){ int now,y,n,T,count; scanf("%d",&T); while(T--){ scanf("%d%d",&y,&n); for(now=y;;now++){ ... 阅读全文
posted @ 2014-08-29 16:50 forever97 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 题解:利用log,先计算答案的log值,n=n*log10(n),然后,最高位就是小数部分幂还原的整数部分。#include #include int T;double n;int main(){ scanf("%d",&T); while(T--){ scanf("%lf... 阅读全文
posted @ 2014-08-29 15:49 forever97 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 题解:简单模拟#include int main(){ int n,tmp,ans,now,pre; while(~scanf("%d",&n)&&n){ ans=0; pre=0; for(int i=0;i0)ans+=(tmp... 阅读全文
posted @ 2014-08-29 15:36 forever97 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 题解:高精度乘法压位。#include #include const int mod=10000;int l,n,a[1000000];int main(){ while(~scanf("%d",&n)){ memset(a,0,sizeof a); a[1]=1;... 阅读全文
posted @ 2014-08-29 15:24 forever97 阅读(128) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;int T,a[1005],n;int main(){ scanf("%d",&T); while(T--){ scanf("%d",&n); for(int i=0;i<n;i++... 阅读全文
posted @ 2014-08-29 14:59 forever97 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 题解:最近点对模板#include #include #include using namespace std;typedef double D;struct Q{D x,y;}q[100001],sl[10],sr[10];int cntl,cntr,lm,rm; D ans;int cmp(Q ... 阅读全文
posted @ 2014-08-29 14:49 forever97 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 欧拉函数,又称为Euler's totient function,在程序编辑中有很大的用途,所以在此总结一下。欧拉函数定义 少于或等于n的数中与n互质的数的数目。欧拉函数求法 因为任意正整数都可以唯一表示成如下形式: n=p1^a1*p2^a2*……*pi^ai 可以推出:Eula... 阅读全文
posted @ 2014-08-28 09:56 forever97 阅读(362) 评论(0) 推荐(0) 编辑
摘要: 题目大意:给你N和K,问有多少个数对满足gcd(N-A,N)*gcd(N-B,N)=N^K。题解:由于 gcd(a, N) 2 都是无解,K=2 只有一个解 A=B=N,只要考虑K=1的情况就好了其实上式和这个是等价的gcd(A,N)*gcd(B,N)=N^K,我们枚举gcd(A,N)=g,那么gc... 阅读全文
posted @ 2014-08-28 09:12 forever97 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 题目大意:给定N,M, 求1=M的个数。题解:首先,我们求出数字N的约数,保存在约数表中,然后,对于大于等于M的约数p[i],求出Euler(n/p[i]),累计就是答案。因为对于每一个大于等于m的约数,GCD(N,t*p[i])=p[i]>=m(t与p[i]互质),所以n除以p[i]的欧拉函数的和... 阅读全文
posted @ 2014-08-27 21:16 forever97 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 题目大意:求小于n的与n不互质的数的和。题解:首先欧拉函数可以求出小于n的与n互质的数的个数,然后我们可以发现这样一个性质,当x与n互质时,n-x与n互质,那么所有小于n与n互质的数总是可以两两配对使其和为n,这也就是为什么当n大于2时欧拉函数都是偶数,知道这一点后,就可以计算出小于n与n互质的数的... 阅读全文
posted @ 2014-08-27 20:39 forever97 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 题解:排序取中位数,然后与平均数比较即可。#include #include using namespace std;double a[1005],ave,med,sum; int n;int main(){ while(~scanf("%d",&n)){ sum=0; ... 阅读全文
posted @ 2014-08-26 14:24 forever97 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 题解:函数式线段树求区间小于等于k的数有几个,离线做法,首先将所有询问和序列一起离散,然后用函数式线段树处理。#include #include #include #include using namespace std;const int N=200005;const int MAXN=3000... 阅读全文
posted @ 2014-08-26 14:09 forever97 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 题解:求区间K小,函数式线段树模板题。#include #include #include using namespace std;const int N=3000005;struct node{int num,id;}a[N];int T,n,m,x,y,z,tot,b[N],head[N],so... 阅读全文
posted @ 2014-08-26 14:04 forever97 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 题解:利用next数组来保存前缀位置,递推求解。#include #include char pat[200005];int next[200005],M,f[200005];const int MOD=10007;int getnext(){ int i=1,j=0;next[1]=0; ... 阅读全文
posted @ 2014-08-22 10:34 forever97 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 题解:将原来的串扩展为两倍,然后用KMP匹配。#include #include char str[200005],pat[100005];int next[100005],N,M;void getnext(){ int i=1,j=0;next[1]=0; while(iM)retur... 阅读全文
posted @ 2014-08-21 19:56 forever97 阅读(121) 评论(0) 推荐(0) 编辑
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 38 下一页