PAT-A-1054. The Dominant Color (20)

1054. The Dominant Color (20)

时间限制
100 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area is called the dominant color. A strictly dominant color takes more than half of the total area. Now given an image of resolution M by N (for example, 800x600), you are supposed to point out the strictly dominant color.

Input Specification:

Each input file contains one test case. For each case, the first line contains 2 positive numbers: M (<=800) and N (<=600) which are the resolutions of the image. Then N lines follow, each contains M digital colors in the range [0, 224). It is guaranteed that the strictly dominant color exists for each input image. All the numbers in a line are separated by a space.

Output Specification:

For each test case, simply print the dominant color in a line.

Sample Input:
5 3
0 0 255 16777215 24
24 24 0 0 24
24 0 24 24 24
Sample Output:
24
#include<iostream>
#include<cstdio>
#include<map>

using namespace std;

int main()
{
  int n, m;
  map<int, int> mp;
  cin >> n >> m;
  int num;
  for (int i = 0; i < n*m; i++)
  {
    cin >> num;
    if (mp.find(num) != mp.end())
      mp[num]++;
    else
      mp[num] = 1;
  }

  int max = 0;
  int k;
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++)
  {
    if (it->second > max)
    {
      k = it->first;
      max = it->second;
    }
  }

  cout << k << endl;
  system("pause");
  return 0;
}

你提到的表达式 `G = (0.00132 s^3 + 0.144 s^2 + 17.35 s + 2.88)` 看起来像是一个连续时间系统的传递函数,通常用于描述动态行为,其中s是复数频率变量(在控制理论中代表角频率)。要将这个3阶系统简化成低阶系统并求取单位阶跃响应,我们首先需要找到它的主导极点,即决定系统响应速度和形状的主要特征根。 主导极点通常是指极点中位于s平面最左侧(离原点最远)的那些,因为它们对系统响应的影响最大。然后我们可以使用典型二阶或一阶系统的形式来近似原始系统,具体取决于主导极点的位置。 简化步骤可能包括: 1. 分析极点分布 2. 如果是多个极点靠近,可能需要进行降阶,如通过适当的积分操作 3. 使用零点-极点匹配方法(如果存在零点) 在Matlab中,你可以使用`tf`函数定义传递函数,`pole`函数找出极点,`ss`函数转换为状态空间形式,然后使用`step`函数计算单位阶跃响应。这里是一个简化示例,但请注意,实际的简化过程需要根据具体分析结果进行: ```matlab % 定义传递函数 G = tf([0.00132, 0.144, 17.35, 2.88], ); % 分析极点 p = pole(G); % 简化前的主导极点位置(假设已知) dominant_pole = p(1); % 这里假设主导极点是第一个 % 根据主导极点选择简化方法 if abs(dominant_pole) > 1 % 高阶系统,考虑二阶化 G_simplified = tf(1, [dominant_pole, 1]); % 单位阶跃响应 step(G_simplified) else % 如果主导极点接近单位圆,可能直接作为一阶系统处理 G_simplified = tf(, [dominant_pole]); % 单位阶跃响应 step(G_simplified) end ``` 注意,上述代码中的`dominant_pole`需要根据实际的极点位置计算。在实际操作中,你可能需要使用更复杂的算法(如Routh-Hurwitz稳定性判据)来确定主导极点,并据此调整简化步骤。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值