2017.08.25 阿里笔试题:自由之路
来源:互联网 发布:调查问卷数据分析方法 编辑:程序博客网 时间:2024/05/16 09:15
真的没想到我能做出来且全部通过,超级开心啊啊啊啊啊。
找到规律就很简单,我一下就想到了01矩阵,矩阵排列是有规律的,在4*4、5*5矩阵中找规律,其实组队个数就等于每两两人相识的总数,这样一想就很简单了。每输入一行就从当前人所在列开始统计1的个数。
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
int m;
cin >> m;
vector<int> count;
int temp;
int temp2 = 0;
char dou;
count.clear();
for (int j=0;j<n;j++)
{
count.push_back(0);
int k =j;
while(k--)
{
cin >>temp;
cin >> dou;
}
for (int i=j;i<m;i++)
{
cin >>temp;
if(i!=m-1) cin >> dou;
if (temp ==1)
{
count[j]++;
}
}
count[j]--;
temp2+=count[j];
}
cout << n-temp2;
return 0;
}
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
int m;
cin >> m;
vector<int> count;
int temp;
int temp2 = 0;
char dou;
count.clear();
for (int j=0;j<n;j++)
{
count.push_back(0);
int k =j;
while(k--)
{
cin >>temp;
cin >> dou;
}
for (int i=j;i<m;i++)
{
cin >>temp;
if(i!=m-1) cin >> dou;
if (temp ==1)
{
count[j]++;
}
}
count[j]--;
temp2+=count[j];
}
cout << n-temp2;
return 0;
}
阅读全文
0 0
- 2017.08.25 阿里笔试题:自由之路
- 阿里云笔试题
- 阿里云笔试题
- 阿里2014笔试题
- 阿里笔试题-选择
- 2015阿里笔试题
- 阿里笔试题
- 阿里的笔试题
- 阿里笔试题
- 阿里笔试题
- 阿里笔试大题
- 阿里笔试第一题
- 2015阿里笔试题
- 阿里笔试题
- 阿里笔试第一题
- 阿里笔试第二题
- 阿里笔试第三题
- 一个阿里笔试题
- USNews2017世界大学排行榜
- centos7+nginx+php安装与配置
- leetcode59. Spiral Matrix II
- 查看Oracle数据库中表的历次统计信息收集的sql
- 实战详解使用PHP Manager for IIS搭建win10系统 IIS 10.0+PHP+MySQL环境
- 2017.08.25 阿里笔试题:自由之路
- Mysql一对多 数据数据查询 数据库
- 剑指offer:替换空格
- 线性方程组个数和方程未知数与方程解的关系
- 初识Spring
- Ubuntu16.04+Cuda8.0+Cudnn+Matlab2014a+OpenCV+Caffe 吐血安装教程
- 积性函数性质-POJ2480
- 数据结构编程笔记十六:第六章 树和二叉树 线索二叉树的实现
- 从俩个有序数组中找出第K小的数。要求时间复杂度O(logmin(m,n))