zoukankan      html  css  js  c++  java
  • HDU 5174

    题意有点不明白,因为MAX为int最大值,推测为64位,AC

    #include <cstdio> 
    #include <iostream> 
    #include <cstring>  
    #include <cctype>  
    #include <algorithm>  
    #define LL __int64
    using namespace std; 
    const LL MAX=2147483647;
    const int N=110;
    LL friends[N];
    int n;LL tot;
    struct Node{
    	LL v,c;
    }node[N];
    bool cmp(LL a,LL b){
    	if(a<b) return true;
    	return false;
    }
    int main(){
    	int t=0;
    	while(scanf("%d",&n)!=EOF){
    		tot=-1;
    		for(int i=0;i<n;i++){
    			scanf("%I64d",&friends[i]);
    			node[i].c=0;
    		}
    		sort(friends,friends+n,cmp);
    		for(int i=0;i<n;i++){
    			if(i==0||friends[i]!=friends[i-1]){
    				node[++tot].v=friends[i];
    				node[tot].c++;
    			}
    			else if(friends[i]==friends[i-1])
    			node[tot].c++;
    		}
    		if(tot==0){
    			printf("Case #%d: -1
    ",++t);
    			continue;
    		}
    		LL now,le,rig; tot++;
    		LL ans=0;
    		for(LL i=0;i<tot;i++){
    			now=i;
    			le=((i-1)%tot+tot)%tot,rig=((i+1)%tot+tot)%tot;
    			if((node[now].v+node[le].v)%MAX==node[rig].v)
    			ans+=node[now].c;
    		}
    		printf("Case #%d: %I64d
    ",++t,ans);
    	}
    	return 0;
    }
    

      

  • 相关阅读:
    JavaEE高级-JPA学习笔记
    jQueryrocket
    jQueryrocket
    jQueryrocket
    jQueryrocket
    jQueryrocket
    jQueryrocket
    jQueryrocket
    jQueryrocket
    jQueryrocket
  • 原文地址:https://www.cnblogs.com/jie-dcai/p/4323097.html
Copyright © 2011-2022 走看看