HDU 1474 HDU1580 UVA570 Always On the Run

Source: Internet
Author: User

I have understood all my questions for a long time. After a long time, I am so sleepy. I have no time to write Analysis in the middle of the night. I have to go to bed and let myself think about it. I will write it tomorrow. There are some cities, each row is a flight from the first city to another city. The cost is zero.

 

 

#include
 
  #include
  
   #include
   
    #include#include
    
     #include
     
      #include
      
       #include
       
        #include
        #include
         
          #include
          
           #include
           
            #include
            
             #define ll long long#define eps 1e-7#define inf 0xfffffffconst ll INF = 1ll<<61;using namespace std;//vector
             
               > G;//typedef pair
              
                P;//vector
               
                 > ::iterator iter;////map
                
                 mp;//map
                 
                  ::iterator p;//int n,k;int dp[10 + 5][1000 + 5];int travel[10 + 5][1000 + 5];int cost[10 + 5][10 + 5][1000 + 5];void clear() {memset(dp,-1,sizeof(dp));memset(travel,0,sizeof(travel));memset(cost,0,sizeof(cost));}int main() {int Case = 0;while(scanf(%d %d,&n,&k),n + k) {clear();for(int i=1;i<=n;i++) {for(int j=1;j<=n;j++) {if(i != j) {scanf(%d,&travel[i][j]);for(int l=0;l
                  
                    dp[l][j - 1] + cost[l][i][tmp])minn = dp[l][j - 1] + cost[l][i][tmp];}dp[i][j] = minn;}}printf(Scenario #%d,++Case);if(dp[n][k] < 0)printf(No flight possible.); elseprintf(The best flight costs %d.,dp[n][k]); }return EXIT_SUCCESS;}
                  
                 
                
               
              
             
            
           
          
         
       
      
     
    
   
  
 


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.