Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

用 费马大定理 失败,这里的数据有重,一个人可以两次听到一棵树

Posted by yuanyirui at 2007-03-30 16:32:06 on Problem 2419
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator