zoukankan      html  css  js  c++  java
  • USACO3.24Feed Ratios

    直接枚举到100水过

     1 /*
     2     ID: shangca2
     3     LANG: C++
     4     TASK: ratios
     5  */
     6 #include <iostream>
     7 #include<cstdio>
     8 #include<cstring>
     9 #include<algorithm>
    10 #include<stdlib.h>
    11 using namespace std;
    12 #define INF 0xfffffff
    13 int a[10][10];
    14 int main()
    15 {
    16     freopen("ratios.in","r",stdin);
    17     freopen("ratios.out","w",stdout);
    18     int i,j,x,y,z,g,o1,o2,o3,o4;
    19     cin>>x>>y>>z;
    20     for(i = 1; i <= 3 ; i++)
    21         for(j = 1; j <= 3 ; j++)
    22         cin>>a[i][j];
    23     int minz = INF;
    24     for(i = 0; i <= 100 ; i++)
    25         for(j = 0 ; j <= 100 ; j++)
    26             for(g = 0 ; g <= 100 ; g++)
    27             {
    28                 int xx = i*a[1][1]+j*a[2][1]+g*a[3][1];
    29                 int yy = i*a[1][2]+j*a[2][2]+g*a[3][2];
    30                 int zz = i*a[1][3]+j*a[2][3]+g*a[3][3];
    31                 if(xx+yy+zz<(x+y+z))
    32                 continue;
    33                 if(double(xx)/double(yy)==double(x)/double(y)&&double(yy)/double(zz)==double(y)/double(z))
    34                 {
    35                     if(minz>(i+j+g))
    36                     {
    37                         o1 = i;
    38                         o2 = j;
    39                         o3 = g;
    40                         o4 = xx/x;
    41                         minz = i+j+g;
    42                     }
    43                 }
    44             }
    45     if(minz!=INF)
    46     cout<<o1<<" "<<o2<<" "<<o3<<" "<<o4<<endl;
    47     else
    48     puts("NONE");
    49     return 0;
    50 }
    View Code
  • 相关阅读:
    CSP-S2019游记
    BZOJ4668 冷战
    [ZJOI2007]仓库建设
    CF833B The Bakery
    决策单调性优化DP+分治优化决策单调性
    穿越栅栏 Overfencing
    控制公司 Controlling Companies
    派对灯 Party Lamps
    CSP2019总结
    差分约束
  • 原文地址:https://www.cnblogs.com/shangyu/p/3268887.html
Copyright © 2011-2022 走看看