Toy Cars (周赛2)

本文介绍了一个关于玩具车竞赛的游戏设置,通过N*N的矩阵记录每辆玩具车在两两碰撞时的结果,以此来判断哪些车在比赛中保持完好无损。文章提供了一段C语言代码,用于读取碰撞数据并输出所有未受损车辆的数量及其编号。

Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.

There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned over, both cars turned over. A car is good if it turned over in no collision. The results of the collisions are determined by an n × n matrixА: there is a number on the intersection of theі-th row and j-th column that describes the result of the collision of theі-th and the j-th car:

  •  - 1: if this pair of cars never collided.  - 1 occurs only on the main diagonal of the matrix.
  • 0: if no car turned over during the collision.
  • 1: if only the i-th car turned over during the collision.
  • 2: if only the j-th car turned over during the collision.
  • 3: if both cars turned over during the collision.

Susie wants to find all the good cars. She quickly determined which cars are good. Can you cope with the task?

Input

The first line contains integer n (1 ≤ n ≤ 100) — the number of cars.

Each of the next n lines contains n space-separated integers that determine matrix A.

It is guaranteed that on the main diagonal there are  - 1, and - 1 doesn't appear anywhere else in the matrix.

It is guaranteed that the input is correct, that is, if Aij = 1, then Aji = 2, if Aij = 3, then Aji = 3, and if Aij = 0, then Aji = 0.

Output

Print the number of good cars and in the next line print their space-separated indices in the increasing order.

Sample test(s)
Input
3
-1 0 0
0 -1 1
0 2 -1
Output
2
1 3 
Input
4
-1 3 3 3
3 -1 3 3
3 3 -1 3
3 3 3 -1
Output
0



大体题意就是有N辆车,组成一个N*N的矩阵,行和列的车进行碰撞,矩阵的主对角线只能是-1,如果为1,则行方向的车被撞翻,为2列方向的车被撞翻,为3行列都没撞翻,0是行列的车都被撞翻,第一行输出没有损坏的车有多少,第二行输出车对应的编号。


#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int map[100][100],a[100],b[100];

int main()
{
    int n,i,j;
    while(~scanf("%d",&n))
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));

        for(i=0;i<n;i++)
            for(j=0;j<n;j++)
            {
                scanf("%d",&map[i][j]);

                if (map[i][j]==1)
                    a[i]=1;
                else if (map[i][j]==2)
                    a[j]=1;
                else if (map[i][j]==3)
                {
                    a[i]=1;
                    a[j]=1;
                }
            }

            int sum=0;

            for(i=0;i<n;i++)
            {
                if(a[i]==0)
                {
                    b[sum++]=i+1;
                }

            }

            printf("%d\n",sum);

            for(i=0;i<sum;i++)
            {
                if(i!=sum-1)
                    printf("%d ",b[i]);
                else
                    printf("%d\n",b[i]);
            }

    }
    return 0;
}


基于STM32 F4的永磁同步电机无位置传感器控制策略研究内容概要:本文围绕基于STM32 F4的永磁同步电机(PMSM)无位置传感器控制策略展开研究,重点探讨在不依赖物理位置传感器的情况下,如何通过算法实现对电机转子位置和速度的精确估计与控制。文中结合嵌入式开发平台STM32 F4,采用如滑模观测器、扩展卡尔曼滤波或高频注入法等先进观测技术,实现对电机反电动势或磁链的估算,进而完成无传感器矢量控制(FOC)。同时,研究涵盖系统建模、控制算法设计、仿真验证(可能使用Simulink)以及在STM32硬件平台上的代码实现与调试,旨在提高电机控制系统的可靠性、降低成本并增强环境适应性。; 适合人群:具备一定电力电子、自动控制理论基础和嵌入式开发经验的电气工程、自动化及相关专业的研究生、科研人员及从事电机驱动开发的工程师。; 使用场景及目标:①掌握永磁同步电机无位置传感器控制的核心原理与实现方法;②学习如何在STM32平台上进行电机控制算法的移植与优化;③为开发高性能、低成本的电机驱动系统提供技术参考与实践指导。; 阅读建议:建议读者结合文中提到的控制理论、仿真模型与实际代码实现进行系统学习,有条件者应在实验平台上进行验证,重点关注观测器设计、参数整定及系统稳定性分析等关键环节。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值