设为首页 加入收藏

TOP

BNU Training 2015 07 27 题解(一)
2015-11-21 00:56:58 来源: 作者: 【 】 浏览:4
Tags:BNU Training 2015 题解

?

uva 12435 C. Consistent Verdicts

【题目大意】:给你二维平面一些人的坐标,每个人手上都有一把枪,求全部人同时开枪后所有人听到枪声的次数的可能数目。

?

【解题思路】:O(n^2)暴力枚举+unique 函数去重相邻元素。居然只跑了3ms,~~

代码:

?

// C
#ifndef _GLIBCXX_NO_ASSERT
#include 
   
     #endif #include 
    
      #include 
     
       #include 
      
        #include 
       
         #include 
        
          #include 
         
           #include 
          
            #include 
           
             #include 
            
              #include 
             
               #include 
              
                #include 
               
                 #include 
                
                  #include 
                 
                   #include 
                  
                    // C++ #include 
                   
                     #include 
                    
                      #include 
                     
                       #include 
                      
                        #include 
                       
                         #include 
                        
                          #include 
                         
                           #include 
                          
                            #include 
                           
                             #include 
                            
                              #include 
                             
                               #include 
                              
                                #include 
                               
                                 #include 
                                
                                  #include 
                                 
                                   #include 
                                  
                                    #include
                                    #include 
                                    
                                      #include 
                                     
                                       #include 
                                      
                                        #include 
                                       
                                         #include 
                                        
                                          #include 
                                         
                                           #include 
                                          
                                            #include 
                                           
                                             #include 
                                            
                                              #include 
                                             
                                               #include 
                                              
                                                #include 
                                               
                                                 #include 
                                                
                                                  #include 
                                                 
                                                   #include 
                                                  
                                                    using namespace std; #define rep(i,j,k) for(int i=(int)j;i<(int)k;++i) #define per(i,j,k) for(int i=(int)j;i>(int)k;--i) #define lowbit(a) a&-a #define Max(a,b) a>b?a:b #define Min(a,b) a>b?b:a #define mem(a,b) memset(a,b,sizeof(a)) typedef long long LL; typedef unsigned long long LLU; typedef double db; const int N=1e6+10; const int inf=0x3f3f3f3f; char str[N]; bool vis[N]; int dir4[4][2]= {{1,0},{0,1},{-1,0},{0,-1}}; int dir8[8][2]= {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}}; int movv[5][2]= {{1,0},{0,1},{0,0},{-1,0},{0,-1}}; inline LL read() { int c=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { c=c*10+ch-'0'; ch=getchar(); } return c*f; } char mon1[N],mon2[N]; LL day1,year1; LL day2,year2; LL row,line,x,t,y,i,res; struct node { LL codrx; LL codry; }; node num[N]; LL mum[N]; int main() { LL tot=1; t=read(); while(t--){ x=read(); int len=0; for(i=0; i
                                                   
                                                  
                                                 
                                                
                                               
                                              
                                             
                                            
                                           
                                          
                                         
                                        
                                       
                                      
                                     
                                    
                                  
                                 
                                
                               
                              
                             
                            
                           
                          
                         
                        
                       
                      
                     
                    
                   
                  
                 
                
               
              
             
            
           
          
         
        
       
      
     
    
   

?

uva 12439 G. February 29

【题目大意】两个日期之间求leap data的个数:ps:常规方法判断会TE,因此换个思路,判断闰年可以用除法 代码:
// C
#ifndef _GLIBCXX_NO_ASSERT
#include 
   
     #endif #include 
    
      #include 
     
       #include 
      
        #include 
       
         #include 
        
          #include 
         
           #include 
          
            #include 
           
             #include 
            
              #include 
             
               #include 
              
                #include 
               
                 #include 
                
                  #include 
                 
                   #include 
                  
                    // C++ #include 
                   
                     #include 
                    
                      #include 
                     
                       #include 
                      
                        #include 
                       
                         #include 
                        
                          #include 
                         
                           #include 
                          
                            #include 
                           
                             #include 
                            
                              #include 
                             
                               #include 
                              
                                #include 
                               
                                 #include 
                                
                                  #include 
                                 
                                   #include 
                                  
                                    #include
                                    #include 
                                    
                                      #include 
                                     
                                       #include 
                                      
                                        #include 
                                       
                                         #include 
                                        
                                          #include 
                                         
                                           #include 
                                          
                                            #include 
                                           
                                             #include 
                                            
                                              #include 
                                             
                                               #include 
                                              
                                                #include 
                                               
                                                 #include 
                                                
                                                  #include 
                                                 
                                                   #include 
                                                  
                                                    using namespace std; #define rep(i,j,k) for(int i=(int)j;i<(int)k;++i) #define per(i,j,k) for(int i=(int)j;i>(int)k;--i) #define lowbit(a) a&-a #define Max(a,b) a>b?a:b #define Min(a,b) a>b?b:a #define mem(a,b) memset(a,b,sizeof(a)) typedef long long LL; typedef unsigned long long LLU; typedef double db; const int N=1e5; const int inf=0x3f3f3f3f; char str[N]; bool vis[N]; int dir4[4][2]= {{1,0},{0,1},{-1,0},{0,-1}}; int dir8[8][2]= {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}}; int movv[5][2]= {{1,0},{0,1},{0,0},{-1,0},{0,-1}}; bool leap_year(int y) { if(y%4==0&&y%100!=0||y%400==0) return 1; return 0; } inline LL read() { int c=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { c=c*10+ch-'0'; ch=getchar(); } return c*f; } char mon1[N],mon2[N]; LL day1,year1; LL day2,year2; LL row,line,x,t,y,i,res; int main() { scanf(%lld,&t); for(i=1; i<=t; ++i) { int res=0; scanf(%s %lld,%lld,mon1,&day1,&year1); scanf(%s %lld,%lld,mon2,&day2,&year2); if((mon1[0]=='J'&&mon1[1]=='a')||mon1[0]=='F') year1=year1; else year1++; if((mon2[0]=='J'&&mon2[1]=='a')||mon2[0]=='F'&&day2<=28) year2--; res=(year2/4)-((year1-1)/4); res=res-(year2/100)+((year1-1)/100); res=res+(year2/400)-((year1-1)/400); printf(Case %lld: %lld ,i,res); } return 0; }
                                                  
                                                 
                                                
                                               
                                              
                                             
                                            
                                           
                                          
                                         
                                        
                                       
                                      
                                     
                                    
                                  
                                 
                                
                               
                              
                             
                            
                           
                          
                         
                        
                       
                      
                     
                    
                   
                  
                 
                
               
              
             
            
           
          
         
        
       
      
     
    
   


uva 12442 J. Forwarding Emails

【题目大意】:酋长发一封信给部落的人,给出部落的人的关系,没人只能收一次且发一次,求在信能传递的最长的的人数链的情况下第一次收到信的人的编号 【解题思路】: 网上看到一个比较直观的思路过程,复制过来,便于理解: Solution Description :

DFS problem
Read this line carefully in problem description - they each pick one other person they know to email those things to every time - exactly one, no less, no more (and never themselves) i.e Each person send email only one. For each person has only one adjacency person. The input can not be (1 to 3, 2 to 3, 1 to 2) , because for person 1 here 2 adjacency person 3 and 2. So, you can repr
首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Codeforces gym 100517(二分,同.. 下一篇HDU 4293 Groups(区间dp)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: