360笔试题
2017-03-09 11:05
127 查看
http://discuss.acmcoder.com/topic/58cd31e475bf559a0653f98f
上面这个是360笔试题
示例代码:
上面这个是360笔试题
跑步:
简单数学题,直接用三角函数计算坐标。#include <bits/stdc++.h> #define maxn 100009 using namespace std; const double PI = acos(-1.0); int main(){ int L,R; scanf("%d%d", &L, &R); double theta = 1.0 * L / R; printf("%.3f %.3f\n", R * cos(-theta), R * sin(-theta)); printf("%.3f %.3f\n", R * cos(theta), R * sin(theta)); return 0; }
剪气球串:
动态规划,考虑前i个有多少种剪法,枚举最后剪的一段转移。示例代码:
#include <bits/stdc++.h> #define maxn 100009 using namespace std; int n; int a[maxn], dp[maxn]; int cnt[11]; const int MOD = 1e9 + 7; int main(){ scanf("%d", &n); for(int i = 1; i <= n; i++){ scanf("%d", &a[i]); } dp[0] = 1; for(int i = 1; i <= n; i++){ memset(cnt, 0 ,sizeof(cnt)); for(int j = 0; j < i; j++){ cnt[a[i - j]]++; if(cnt[a[i - j]] > 1) break; dp[i] = (dp[i] + dp[i - j - 1]) % MOD; } } printf("%d\n", dp ); return 0; }
冒泡,快排,二分查找
#include <iostream> #include <vector> using namespace std; void bubbleSort(vector<int>& toBeSortedNums){ for (int i = 0; i < toBeSortedNums.size(); i++){ for (int j = 0; j < toBeSortedNums.size() - 1 - i; j++){ if (toBeSortedNums[j] > toBeSortedNums[j + 1]){ int temp = toBeSortedNums[j]; toBeSortedNums[j] = toBeSortedNums[j + 1]; toBeSortedNums[j + 1] = temp; } } } } void quickSort(int array[], int low, int high){ if (low >= high) return; int first = low; int last = high; int key = array[first]; while (first < last){ while (first < last && array[last] >= key) last--; array[first] = array[last];//小的放前面 while (first < last && array[first] <= key) first++; array[last] = array[first];//大的放后面 } array[first] = key; quickSort(array, low, first - 1); quickSort(array, first + 1, high); } int binSerch(int array[], int start, int end, int key){ int mid; while (start <= end){ if (array[start] == key) return start; if (array[end] == key) return end; mid = start + (end - start) / 2; if (array[mid] == key) return mid; if (array[mid] < key) start = mid + 1; if (array[mid] > key) end = mid - 1; } if (start > end) return -1; } int main(){ vector<int> toBeSortedNums = { 22, 11, 3, 4, 6, 7, 9, 21, 12, 34, 55, 28, 19 }; bubbleSort(toBeSortedNums); int array[] = { 22, 11, 3, 4, 6, 7, 9, 21, 12, 34, 55, 28, 19 }; quickSort(array, 0, sizeof(array) / sizeof(array[0]) - 1); int res = binSerch(array, 0, sizeof(array) / sizeof(array[0]) - 1, 9); return 0; }
相关文章推荐
- [360] 笔试题2012年最后一道大题
- 360 2015年在线笔试题:最后一个字符
- 360笔试题————计算器格式输出一个数的素因子乘积
- 2014年360校园招聘笔试题,干货分享
- 【第14题】360校园招聘2015届技术类笔试题
- 华为IT应用开发工程师(C++应用软件)实习生笔试+360企业安全服务端开发工程师实习生笔试
- 百度、腾讯、搜狐、360等产品职位笔试智力题分析
- 2016届 360校招内推笔试题--2015.8.11
- 笔试题:360找镇长的题。
- [360] 笔试题2012年最后一道大题
- 行编辑器 2016年360笔试题目 字符串处理
- 滴滴打车And 360 校招 2016 在线笔试(二)
- 360笔试题——找老乡
- 2012.4.13 360笔试总结
- 2017.08.26 360笔试题:小明卖粉笔
- 360的笔试题
- 2016 360笔试 编程题 2
- 360今年笔试题之一:整数分解为素因子,并用用九字段数字表示出来的代码
- 360(2017春季笔试题)跑步
- 360 2013校园招聘笔试题(含参考答案)