全场梦游。。考研狗好久没码题了已经跪了T T

被自己蠢哭

题目1 : Farthest Point

时间限制:5000ms
单点时限:1000ms
内存限制:256MB

描述

Given a circle on a two-dimentional plane.

Output the integral point in or on the boundary of the circle which has the largest distance from the center.

输入

One line with three floats which are all accurate to three decimal places, indicating the coordinates of the center x, y and the radius r.

For 80% of the data: |x|,|y|<=1000, 1<=r<=1000

For 100% of the data: |x|,|y|<=100000, 1<=r<=100000

输出

One line with two integers separated by one space, indicating the answer.

If there are multiple answers, print the one with the largest x-coordinate.

If there are still multiple answers, print the one with the largest y-coordinate.

样例输入
1.000 1.000 5.000
样例输出
6 1

求离圆心最远的整点

思路:

暴力流,注意到X范围有限,枚举之。

接下来有两种方法

1.列方程解出Y,枚举附近点。

2.分上下半圆二分Y

注意精度。。。

#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
int dcmp(double x){if(fabs(x) < eps)return 0;return x < 0 ? -1 : 1;
}
int main(){double x, y, r;int left, right;double ansdis = -1;int ansx, ansy;cin >> x>> y >>r;left = ceil(x - r);right = floor(x + r);for(int i = right; i >= left; i--){int nowx = i;int high = floor(y + r),low = ceil(y),mid;int nowy = -INF;while(low <= high){mid = (low + high) >> 1;if(dcmp((mid-y)*(mid-y)+(i-x)*(i-x) - r* r) <= 0){nowy = mid;low = mid + 1;}else high = mid - 1;}if(nowy != -INF){double nowdis = (nowx-x)*(nowx-x)+(nowy-y)*(nowy-y);if(dcmp(nowdis - ansdis) > 0){ansx = i;   ansy = nowy;ansdis = nowdis;}}nowy = -INF;high = floor(y),low = ceil(y-r);while(low <= high){mid = (low + high) >> 1;if(dcmp((mid-y)*(mid-y)+(i-x)*(i-x) - r* r) <= 0){nowy = mid;high = mid - 1;}else low = mid + 1;}if(nowy != -INF){double nowdis = (nowx-x)*(nowx-x)+(nowy-y)*(nowy-y);if(dcmp(nowdis - ansdis) > 0){ansx = i;   ansy = nowy;ansdis = nowdis;}}}cout << ansx << " " << ansy << endl;return 0;
}

View Code

题目2 : Total Highway Distance

时间限制:10000ms
单点时限:1000ms
内存限制:256MB

描述

Little Hi and Little Ho are playing a construction simulation game. They build N cities (numbered from 1 to N) in the game and connect them by N-1 highways. It is guaranteed that each pair of cities are connected by the highways directly or indirectly.

The game has a very important value called Total Highway Distance (THD) which is the total distances of all pairs of cities. Suppose there are 3 cities and 2 highways. The highway between City 1 and City 2 is 200 miles and the highway between City 2 and City 3 is 300 miles. So the THD is 1000(200 + 500 + 300) miles because the distances between City 1 and City 2, City 1 and City 3, City 2 and City 3 are 200 miles, 500 miles and 300 miles respectively.

During the game Little Hi and Little Ho may change the length of some highways. They want to know the latest THD. Can you help them?

输入

Line 1: two integers N and M.

Line 2 .. N: three integers u, v, k indicating there is a highway of k miles between city u and city v.

Line N+1 .. N+M: each line describes an operation, either changing the length of a highway or querying the current THD. It is in one of the following format.

EDIT i j k, indicating change the length of the highway between city i and city j to k miles.

QUERY, for querying the THD.

For 30% of the data: 2<=N<=100, 1<=M<=20

For 60% of the data: 2<=N<=2000, 1<=M<=20

For 100% of the data: 2<=N<=100,000, 1<=M<=50,000, 1 <= u, v <= N, 0 <= k <= 1000.

输出

For each QUERY operation output one line containing the corresponding THD.

样例输入
3 5
1 2 2
2 3 3
QUERY
EDIT 1 2 4
QUERY
EDIT 2 3 2
QUERY
样例输出
10
14
12

全场最水题?给一棵树,以及边权,定义THD为点两两之间的距离和,一边修改一边查询THD的值思路:另其有根,设深度较深的Y,浅的为X, 则X必为Y的父亲。一条边链接X, Y,则其影响Y子树与外部的距离,即cnt[y]*(n-cnt[y])的贡献。处理出子树规模。记录每个点的深度及通向其父亲的边是哪一条。没了

#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
typedef long long ll;
struct Edge{int x, y, w, next;Edge(){};Edge(int u, int v, int z, int dis){x = u, y = v, next = z, w = dis;}
}edge[N<<1];int cntson[N], head[N], deep[N];
int faedge[N];int no;
ll ans;
void init(){memset(head, -1, sizeof(head));memset(cntson, 0, sizeof(cntson));no = 0;
}void add(int x, int y, int z){edge[no] = Edge(x, y , head[x], z);head[x] = no++;edge[no] = Edge(y, x, head[y], z);head[y] = no++;
}void dfs(int x, int fa){int i, y;cntson[x] = 1;for(i = head[x]; i != -1; i = edge[i].next){y = edge[i].y;if(y == fa)continue;deep[y] = deep[x] + 1;dfs(y, x);cntson[x] += cntson[y];faedge[y] = i;}
}
int main(){int n, m, x, y, z, i;char op[10];init();scanf("%d%d", &n, &m);for(i = 1; i < n; i++){scanf("%d%d%d", &x, &y, &z);add(x, y, z);}deep[1] = 0;dfs(1, 1);for(i = 0; i < no; i+=2){x = edge[i].x;  y = edge[i].y;if(deep[x] > deep[y])   swap(x, y);ans += (ll)(cntson[y])*(n - cntson[y])*edge[i].w;}while(m--){scanf("%s", op);if(op[0] == 'Q'){printf("%lld\n", ans);}else{scanf("%d%d%d",&x, &y, &z);if(deep[x] > deep[y])   swap(x, y);i = faedge[y];ans += (ll)(z - edge[i].w) * (cntson[y])*(n - cntson[y]);edge[i].w = z;}}return 0;
}

View Code

题目3 : Fibonacci

时间限制:10000ms
单点时限:1000ms
内存限制:256MB

描述

Given a sequence {an}, how many non-empty sub-sequence of it is a prefix of fibonacci sequence.

A sub-sequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.

The fibonacci sequence is defined as below:

F1 = 1, F2 = 1

Fn = Fn-1 + Fn-2, n>=3

输入

One line with an integer n.

Second line with n integers, indicating the sequence {an}.

For 30% of the data, n<=10.

For 60% of the data, n<=1000.

For 100% of the data, n<=1000000, 0<=ai<=100000.

输出

One line with an integer, indicating the answer modulo 1,000,000,007.

样例提示

The 7 sub-sequences are:

{a2}

{a3}

{a2, a3}

{a2, a3, a4}

{a2, a3, a5}

{a2, a3, a4, a6}

{a2, a3, a5, a6}

样例输入
6
2 1 1 2 2 3
样例输出
7

处理出所有FIB值。对于Ai,若其为FIB,则求出她是第几个(fibj),设cnt[j-1]为所有长度为j-1的符合题意的序列个数。则cnt[j] += cnt[j-1];特别处理一下x=1的时候。。

最后统计所有cnt就行了。注意取模= =

#include<bits/stdc++.h>
using namespace std;
const int N = 33;
const int MOD = 1000000007;typedef long long ll;int fib[N];
ll cnt[N];
bool vis[N];
int main(){int n, i,j, x;memset(fib, -1, sizeof(fib));memset(vis, 0, sizeof(vis));fib[1] = 1;fib[2] = 1;for(i = 3; fib[i-1] <= 100000; i++){fib[i] = fib[i-1] + fib[i-2];//printf("%d %d\n", i, fib[i]);
    }//fib[25]//1!!!!!!!!!!!!!!
memset(cnt, 0, sizeof(cnt));ll ans = 0;scanf("%d", &n);for(i = 1; i <= n; i++){scanf("%d", &x);if(x == 1){cnt[2] =(cnt[1] + cnt[2]) % MOD;cnt[1] ++;if(cnt[2] >=1)  vis[2] = true;continue;}ll tmp = 1;for( j = 3; j <= 25 && fib[j] <= x; j++){if(x == fib[j]) break;}if(x == fib[j]) {if(vis[j-1]){cnt[j] = (cnt[j] + cnt[j-1]) % MOD;vis[j] = true;}}// cout << i << " " << ans<<endl;
    }for(i = 1; i <= 25; i++){ans = (ans + cnt[i]) % MOD;}cout << ans<<endl;return 0;
}

View Code

题目4 : Image Encryption

时间限制:10000ms
单点时限:1000ms
内存限制:256MB

描述

A fancy square image encryption algorithm works as follow:

0. consider the image as an N x N matrix

1. choose an integer k∈ {0, 1, 2, 3}

2. rotate the square image k * 90 degree clockwise

3. if N is odd stop the encryption process

4. if N is even split the image into four equal sub-squares whose length is N / 2 and encrypt them recursively starting from step 0

Apparently different choices of the k serie result in different encrypted images. Given two images A and B, your task is to find out whether it is POSSIBLE that B is encrypted from A. B is possibly encrypted from A if there is a choice of k serie that encrypt A into B.

输入

Input may contains multiple testcases.

The first line of the input contains an integer T(1 <= T <= 10) which is the number of testcases.

The first line of each testcase is an integer N, the length of the side of the images A and B.

The following N lines each contain N integers, indicating the image A.

The next following N lines each contain N integers, indicating the image B.

For 20% of the data, 1 <= n <= 15

For 100% of the data, 1 <= n <= 100, 0 <= Aij, Bij <= 100000000

输出

For each testcase output Yes or No according to whether it is possible that B is encrypted from A.

样例输入
3
2
1 2
3 4
3 1
4 2
2
1 2
4 3
3 1
4 2
4
4 1 2 3
1 2 3 4
2 3 4 1
3 4 1 2
3 4 4 1
2 3 1 2
1 4 4 3
2 1 3 2
样例输出
Yes
No
Yes

赛时犯了一个极其脑残的错误导致样例都过不去。。。泪目。。。。。。。。。。T T暴力了一个写法,不知道能不能过。等题库放题了再改吧【update:能过】

#include <bits/stdc++.h>
using namespace std;const int N = 104;
int gox[4] = {1, 1, -1, -1};
int goy[4] = {1, -1, -1, 1};
struct Matrix{int f[N][N];int mat_size;void scan(){int i, j;for(i = 1; i <= mat_size; i++)for(j = 1; j <= mat_size; j++)scanf("%d", &f[i][j]);}void print(){int i, j;for(i = 1; i <= mat_size; i++){for(j = 1; j <= mat_size; j++)printf("%d ", &f[i][j]);printf("\n");}}void modify(int t, int ra, int rb, int ca, int cb){Matrix C;int i, j, ii, jj;if(t & 1){if(t == 1){for(j = cb, ii = ra; j >= ca; j--, ii++)for(i = ra, jj = ca; i <= rb; i++, jj++)C.f[ii][jj] = f[i][j];}else{for(j = ca, ii = ra; j <= cb; j++, ii++)for(i = rb, jj = ca; i >= ra; i--, jj++)C.f[ii][jj] = f[i][j];}}else{for(i = rb, ii = ra; i >= ra; i--, ii++)for(j = cb, jj = ca; j >= ca; j--, jj++)C.f[ii][jj] = f[i][j];}for(i = ra; i <= rb; i++)for(j = ca; j <= cb; j++)f[i][j] = C.f[i][j];}bool check(const Matrix &I, int ra, int rb, int ca, int cb)const{int i, j;for(i = ra; i <= rb; i++)for(j = ca; j <= cb; j++)if(f[i][j] != I.f[i][j])    return false;return true;}
}A, B;bool judge(Matrix &A, Matrix &B, int ra, int rb, int ca, int cb){int i;Matrix Tmp = A;for(i = 0; i < 4; i++){if(i != 0)A.modify(i, ra, rb, ca, cb);if(((ra - rb + 1) &1 )){if(B.check(A, ra, rb, ca, cb)) return true;}else{if(B.check(A, ra, rb, ca, cb))return true;if(judge(A, B, ra, (ra + rb) / 2, ca, (ca+cb)/2) &&judge(A, B, (ra + rb) / 2+1, rb, (ca + cb) / 2 + 1, cb)&&judge(A, B, ra, (ra + rb) / 2, (ca + cb) / 2 + 1, cb) &&judge(A, B, (ra + rb) / 2+1, rb, ca, (ca+cb)/2))return true;}A = Tmp;}return false;
}
int main(){int n, TC, i, j;scanf("%d", &TC);while(TC--){scanf("%d", &n);A.mat_size = B.mat_size = n;A.scan();B.scan();printf("%s\n", judge(A, B, 1, n, 1, n)?"Yes" : "No");//  A = A.modify(1, 1,n, 1, n);// A.print();
    }return 0;
}

View Code

转载于:https://www.cnblogs.com/bbbbbq/p/4847429.html

微软2016 9月笔试相关推荐

  1. 微软2016校园招聘9月在线笔试题解

    微软2016校园招聘9月在线笔试题解 题目网址列表:http://hihocoder.com/contest/mstest2015sept2/problems 题目一分析: 问题描述:在二维坐标系中, ...

  2. 计算机考试93781试题及答案,黄南州中小学教师2016年招聘笔试加分人员名单(3 )...

    林奇娟 93235 少数民族 23201021-小学汉语文教师 报考少数民族地区的少数民族 5 加杨尖措 93238 少数民族 23201018-小学美术教师 报考少数民族地区的少数民族 5 李毛才让 ...

  3. 重庆计算机一级考试2016年,重庆计算机一级考试真题2016年最新(笔试+上机)讲述.doc...

    重庆计算机一级考试真题2016年最新(笔试上机)讲述 重庆计算机1级考试真题(笔试+上机) [2014~2016年]一级笔试真题 一.选择题 1.微机中1K字节表示的二进制位数是( ). A.1000 ...

  4. dp - 2016腾讯笔试 A

    2016腾讯笔试 A Problem's Link -------------------------------------------------------------------------- ...

  5. 微软发布5月补丁星期二:3个0day,1个蠕虫

     聚焦源代码安全,网罗国内外最新资讯! 编译:奇安信代码卫士 微软发布5月补丁星期二,共修复了55个漏洞,其中4个是"严重"级别,3个是0day 漏洞. 3个 0day 已遭公开 ...

  6. 微信与此ipad不兼容电脑也显示设备版本过低9.0_iOS系统出现怪异Bug:iPhone/iPad没法正常用;微软计划6月开测Windows 10 21H1更新...

    IT服务圈儿 有温度.有态度的IT自媒体平台  开发者头条  1.Microsoft Edge 83 稳定版发布 微软推出了 Microsoft Edge 83 稳定版(83.0.478.37),现在 ...

  7. 神州数码c语言笔试题,2016年计算机笔试考试题及答案

    2016年计算机笔试考试题及答案 2016年计算机等级考试就要开始了,同学们复习好了吗?下面yjbys小编为大家准备的是关于网络笔试的考试题及答案,希望能帮助大家顺利通过考试! [字符串] 1.输入一 ...

  8. [Hihocoder 1289] 403 Forbidden (微软2016校园招聘4月在线笔试)

    传送门 #1289 : 403 Forbidden 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi runs a web server. Someti ...

  9. 微软2016校园招聘4月在线笔试 hihocoder 1288 Font Size (模拟)

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Steven loves reading book on his phone. The book he reads now ...

最新文章

  1. aaynctask控制多个下载进度_AsyncTask用法解析-下载文件动态更新进度条
  2. C语言经典例76-根据n的奇偶性累加
  3. js ie 6,7,8 使用不了 firstElementChild
  4. [react] 使用webpack打包React项目,怎么减小生成的js大小?
  5. STL源码剖析 配接器
  6. 一维战舰(51Nod-1521)
  7. 局域网IP搜索小工具
  8. 视频教程-基于VUE和Hplus通用后台管理系统(前端篇)-Vue
  9. graphpad做折线图_GraphPad 折线图要这样玩
  10. laravel 框架中的路由
  11. 安卓App启动流程详解
  12. day1------安装部署k8s之完成(3)
  13. 一文搞懂HTTP协议(带图文)
  14. 我在Facebook工作四年的总结与反思
  15. 一战北邮计专考研经验分享
  16. gphp32.exe是什么文件?
  17. [详解] iphone手机备份、升级流程
  18. [AV1] AV1 Reference Software
  19. 机器学习和人工智能发展简史
  20. Oracle卸载卸不干净,Oracle彻底删除的办法(winxp)

热门文章

  1. 搜索引擎、相关性算法的测试
  2. Mr.J---重拾Ajax(四)-- 跨域
  3. 《密码与安全新技术专题》第1周作业
  4. window环境下安装Python2和Python3
  5. Javascript中类型的判断
  6. python random从集合中随机选择元素
  7. wp8对json的处理
  8. [Node.js] 模块化 -- path路径模块
  9. jQuery源码研究分析学习笔记-回调函数(11)
  10. 用jQuery和css3实现的一个模仿淘宝ued博客左边的菜单切换动画效果