华电北风吹
天津大学认知计算与应用重点实验室
日期:2015/8/21

这三道题目的PDF能够在这里下载
https://github.com/ncepuzhengyi/jobHuntingExam/tree/master/jobExam/Problem_20150815_google

Problem 1:
问题1是眼下须要将阻止分成两块,因为组织内有些人之间有矛盾不能分到同一组内。问你是否存在这种划分。

问题一是二分图推断问题,仅仅须要推断无向图是否是二分图就可以。

最简单的方法是採用广度优先搜索+染色法就可以。

#include <iostream>
#include <string>
#include <fstream>
#include <map>
#include <deque>
using namespace std;#define size 5
int graph[size][size];
int visited[size];
int color[size];bool  GraphJudge(int nodeNum)
{memset(visited, 0, sizeof(visited));memset(color, 0, sizeof(color));for (int k = 0; k < nodeNum; k++){if (visited[k] == 0){visited[k] = 1;color[k] = 1;deque<int> q;q.push_back(k);while (q.empty()==false){int i = q.front();q.pop_front();for (int j = 0; j < nodeNum; j++){if (graph[i][j] > 0 && i!=j){if (visited[j] == 0){q.push_back(j);visited[j] = 1;color[j] = 1 - color[i];}else{if (color[j] == color[i])return false;}}}}}}return true;
}int main(int argc, char* argv[])
{ifstream in(".\\input.txt");cin.rdbuf(in.rdbuf());int T;cin >> T;cin.ignore();for (int caseNum = 0; caseNum<T; caseNum++){int M;cin >> M;memset(graph, 0, sizeof(&graph));map<string, int> nameIndex;map<string, int>::iterator it;int nodecount = 0;for (int i = 0; i < M; i++){int start, end;string p;cin >> p;it = nameIndex.find(p);if (it == nameIndex.end()){nameIndex[p] = nodecount;nodecount++;}start = nameIndex[p];cin >> p;it = nameIndex.find(p);if (it == nameIndex.end()){nameIndex[p] = nodecount;nodecount++;}end = nameIndex[p];graph[start][end] = 1;}if (GraphJudge(nodecount))cout << "Case #" << caseNum + 1 << ":" << "Yes" << endl;elsecout << "Case #" << caseNum + 1 << ":" << "No" << endl;}system("pause");return 0;
}

Problem 2:
问题二确切的说应该算作一个高中物理题,给出斜抛初速度和距离,计算斜抛初始角度。

#include<iostream>
#include <math.h>
#include <iomanip>
#include <ostream>
#include <fstream>
using namespace std;int main(int argc, char* argv[])
{//ifstream in("C:\\Users\\zhengyi\\Desktop\\ConsoleApplication1\\Debug\\input.txt");//streambuf *cinbuf = cin.rdbuf(); //save old buf//cin.rdbuf(in.rdbuf()); //redirect std::cin to in.txt!//ofstream out("C:\\Users\\zhengyi\\Desktop\\ConsoleApplication1\\Debug\\out.txt");//streambuf *coutbuf = std::cout.rdbuf(); //save old buf//cout.rdbuf(out.rdbuf()); //redirect std::cout to out.txt!//std::cin.rdbuf(cinbuf);   //reset to standard input again//std::cout.rdbuf(coutbuf); //reset to standard output againint T;cin >> T;int k = 0;while (k < T){int V, D;cin >> V >> D;double theta = asin(9.8 * D / (V * V)) * 90 / 3.14159265;cout << "Case #" << k + 1 <<":"<< fixed << setprecision(7) << theta << endl;k++;}return 0;
}

Problem 3:
第三题操作过程是一种相似于插入排序的排序机制,对于接下来的元素。须要往前插入的话就耗费1$。以此计算总共花费。

#include <iostream>
#include <string>
#include <vector>
#include <ostream>
#include <fstream>
using namespace std;int main(int argc, char* argv[])
{//ifstream in("C:\\Users\\zhengyi\\Desktop\\ConsoleApplication1\\Debug\\input.txt");//streambuf *cinbuf = cin.rdbuf(); //save old buf//cin.rdbuf(in.rdbuf()); //redirect std::cin to in.txt!//ofstream out("C:\\Users\\zhengyi\\Desktop\\ConsoleApplication1\\Debug\\out.txt");//streambuf *coutbuf = std::cout.rdbuf(); //save old buf//cout.rdbuf(out.rdbuf()); //redirect std::cout to out.txt!//std::cin.rdbuf(cinbuf);   //reset to standard input again//std::cout.rdbuf(coutbuf); //reset to standard output againint N;cin >> N;for (int i = 0; i < N; i++){int n;cin >> n;int count = 0;cin.sync();string str;vector<string> v1;while (count<n) {getline(cin, str);v1.push_back(str);count++;}//v1.erase(v1.begin());int cost = 0;for (int k = 1; k < n; k++){string key = v1[k];int t = k - 1;if (t >= 0 && v1[t].compare(key) > 0){v1[t + 1] = v1[t];t--;cost++;}v1[t + 1] = key;}cout << "Case #" << i + 1 << ":" << cost << endl;}return 0;
}

三道题目的代码
https://github.com/ncepuzhengyi/jobHuntingExam

以下这个是另外一次google的笔试题目。仅仅收集到了这一道
Problem 4
S0 = ”
S1 = ‘0’
S2 = ‘001’
S3 = ‘0010011’
S4 = ‘001001100011011’
……
SN = SN + ‘0’ + not(reverse( SN ))
reverse是字符串反转
not是0,1转换
求S1010000 的第k个数
small data set: k<105
large data set: k<1018

from math import log
from math import ceildef Nlen(n):return pow(2,n)-1def LineNum(k):return ceil(log(k+1,2))r=True
def func(x):global rlastNum=LineNum(x)if x==pow(2,lastNum-1):if r:return '0'else:return '1'if x==1:if r:return '1'else:return '0'if r:r=Falseelse:r=Truereturn func(pow(2,lastNum)-x)s4=''
for i in range(1,16):r=Trues4+=func(i)
print(s4)

Google笔试(2015年8月)相关推荐

  1. 面试----2015阿里巴巴5月校园实习生招聘(笔试、一面、二面+Hr面)

    2015年3月份有投阿里巴巴研发工程师JAVA岗,当时是内推的,内推免笔试,直接到就是电话一面,那段时间周围大多数内推的同学都接到了电面,由于是过年刚来几天就开始面试,所以大部分同学处于未准备好的阶段 ...

  2. [笔试题目] 美团2015年9月后端开发工程师笔试题

    由于题目是我通过草稿回顾,可能表述不清,但是内容大致一样.希望该博客内容对你有所帮助,题目所有权归美团公司所有,我只是想分享给大家学习,还望贵公司海涵~ 面试职位 应聘职位:后端开发工程师 岗位描述: ...

  3. 阿里电话面试之所做所得所感(2015年7月)

    原文地址:http://blog.csdn.net/eastmount/article/details/46829073 转眼间就到了找工作的阶段,这是我参加的第一个面试,无论结果如何我都受益匪浅.以 ...

  4. 【Android NDK 开发】Android NDK 下载 ( 下载指定历史版本 NDK | Android NDK r10e - 2015 年 5 月 )

    文章目录 一.下载指定历史版本 NDK 一.下载指定历史版本 NDK 进入到 ndk 下载的 " 修订历史记录 " 页面 https://developer.android.goo ...

  5. 2015年3月-前端开发月刊

    1. 创业 2. 职业|项目管理 3. git 4. 知乎(zhihu) 5. 其它 6. Angular 7. 看书学习 8. 移动开发 9. Html5 10. CSS3 11. Javascri ...

  6. TIOBE 2015年6月编程语言排行榜

    TIOBE排行榜是根据互联网上有经验的程序员.课程和第三方厂商的数量,并使用搜索引擎(如Google.Bing.Yahoo!.百度)以及Wikipedia.Amazon.YouTube统计出排名数据, ...

  7. Google笔试集锦

    http://bbs.yingjiesheng.com/thread-21638-1-1.html 选择题+三道算法题 选择题没什么难的  最后一道考的数据库使用什么存储结构不会做.. 算法题 第一题 ...

  8. listview 争夺焦点_浏览器趋势2015年6月:争夺第二名

    listview 争夺焦点 In last month's browser chart, Chrome was 0.03% away from the 50% milestone. Has it re ...

  9. 扒一扒HTTPS网站的内幕[2015年09月29日]

    扒一扒HTTPS网站的内幕 野狗 2015年09月28日发布 作者:王继波  野狗科技运维总监,曾在360.TP-Link从事网络运维相关工作,在网站性能优化.网络协议研究上经验丰富. 野狗官博:ht ...

最新文章

  1. 对Squid使用的一些总结
  2. DllMain中不当操作导致死锁问题的分析——线程中调用GetModuleFileName、GetModuleHandle等导致死锁
  3. 操作系统之(一篇文章让你简单搞定:什么是进程和线程)
  4. 贵!iPhone 11系列维修费用出炉 最高的可以入手一部华为P30 Pro了…
  5. Spring :基于@Transactional注解的声明式事物
  6. StringBuffer,StringBuilder区别是啥
  7. POJ3126 Prime Path(BFS)
  8. 根据表格长度使td里的内容换行
  9. mac文件修改权限设置
  10. [转]C#反射,根据反射将数据库查询数据和实体类绑定,并未实体类赋值
  11. 爬虫第十一式:用selenium爬取民政部行政区划代码
  12. git出现绿色、红色状态的deleted
  13. Atitit MP3元数据抽取结果 音乐信息检索 取出了重复和英文的数据 一共368个。。 /bookmarksHtmlEverythingIndexPrj/src/apkg/songlistC
  14. pwnable.kr 第一题fd
  15. python数字不同数之和_python练习 数字不同数之和+人名最多数统计
  16. error: undefined reference to ‘_imp___ZN12QApplicationC1ERiPPci‘
  17. oracle的多个exclude,expdp exclude 如何使用 - 同一schema下3000个表,要剔除其中400多张表...
  18. 产品读书《极简生活法则》
  19. python神经网络构建图_如何用卷积神经网络构建图像?
  20. zoom如何使用网页版登录

热门文章

  1. python商业爬虫教程_廖雪峰老师的Python商业爬虫课程 Python网络爬虫实战教程 体会不一样的Python爬虫课程...
  2. django-Modelform
  3. case when用法
  4. 【Zookeeper】Zookeeper部署笔记
  5. CUBRID学习笔记 1 简介 cubrid教程
  6. 关于C# WinForm中进度条的实现方法
  7. XAML 编辑调试工具 Kaxaml
  8. 原生js中如果有多个onload事件解决方案
  9. phalcon: 解决php7/phalcon3.2以上版本,不支持oracle数据库的方法
  10. 关于解决多台linux服务器间的文件实时同步问题