Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:虽然费马大定理使用失败了,但这种降维的想很精彩,似乎有点HASH的影子!赞一个!In Reply To:用 费马大定理 失败,这里的数据有重,一个人可以两次听到一棵树 Posted by:yuanyirui at 2007-03-30 16:32:06 > #include <stdio.h> > #include <iostream> > using namespace std; > int main() > { > // freopen("in.txt","r",stdin); > // freopen("out.txt","w",stdout); > int p,n; > int s[100],i,a,b,tmp,ans; > scanf("%d%d",&p,&n); > for(i=1;i<=p;i++) s[i]=0; > while(scanf("%d%d",&a,&b)!=EOF){ > s[a] += b*b*b; //如果数据不出现重复,把多维映射到一维就没有问题 > } > sort(s+1,s+p); > ans=0; > for(i=1,tmp=-1;i<=p;i++){ > if(s[i]>tmp){ > tmp=s[i]; > ans++; > } > } > printf("%d\n",ans); > return 1; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator