Announcement

Collapse
No announcement yet.

[ThuậtToán2017] Buổi 11 - Qui hoạch động - 9:45 ngày thứ năm 27/7 tại A325

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [ThuậtToán2017] Buổi 11 - Qui hoạch động - 9:45 ngày thứ năm 27/7 tại A325

    Buổi 11 - Qui hoạch động - 9:45 ngày thứ năm 27/7/2017 tại A325
    Sau buổi học, GV sẽ cập nhật thêm nội dung.
    Attached Files
    Last edited by toannv; 26-07-2017, 12:44.

  • #2
    sao chuyen gio qua hoc ngay bua nay the thay

    Comment


    • #3
      [QUOTE=15521025;371036]sao chuyen gio qua hoc ngay bua nay the thay[/QUOTE
      Chào em!
      Hôm nay là thứ tư 26/7 mà em.

      Comment


      • #4
        PHP Code:
        #include <stdio.h>
        #include <conio.h>

        int w[100]={4,5,1,2,6,3};
        int v[100]={5,6,5,4,7,6};
        int M=14N=6;

        int max(int a,int b)
        {
            if (
        a>b) return a; return b;
        }
        int MaxV(int KLint i)
        {
            if (
        KL <= 0) return 0;
            else if (
        == -1) return 0;
            else
            
        // Lay vat i:v[i]+ MaxV(KL-w[i],i-1)
            // Khong lay vat i: MaxV(KL,i-1)
            
        {
                 if (
        KL>=w[i]) return  max(v[i]+ MaxV(KL-w[i],i-1), MaxV(KL,i-1));
                 else return 
        MaxV(KL,i-1);
            }
        }
        int main()
        {
            
        printf("%d",MaxV(M,N-1));
            return 
        0;

        Comment


        • #5
          PHP Code:

          #include <stdio.h>
          #include <conio.h>

          int w[100]={4,5,1,2,6,3};
          int v[100]={5,6,5,4,7,6};
          int M=14N=6;
          int t[100], maxx;
          int max(int a,int b,int i)
          {
              if (
          a>b)
              {
                  
          t[i]= 1;
                  
          maxx=a;
                  return 
          a;
              }
              
          t[i]=0;
              
          maxx=b;
              return 
          b;
          }
          int MaxV(int KLint i)
          {
              if (
          KL <= 0) return 0;
              else if (
          == -1)
              {
                  
          //printf("%d\t%d\t%d\n",);
                  
          int i;
                  for ( 
          i=0;i<N;i++) printf("%d\t",t[i]);
                  
          printf(" - max%d\n",maxx);
                  return 
          0;
              }
              else
              
          // Lay vat i:v[i]+ MaxV(KL-w[i],i-1)
              // Khong lay vat i: MaxV(KL,i-1)
              
          {
                   if (
          KL>=w[i]) return  max(v[i]+ MaxV(KL-w[i],i-1), MaxV(KL,i-1),i);
                   else {
          t[i]=0;return MaxV(KL,i-1);};
              }
          }
          int main()
          {
              
          printf("%d",MaxV(M,N-1));
              return 
          0;

          Comment

          LHQC

          Collapse
          Working...
          X