7.14-2014新生暑假个人排位赛01
来源:互联网 发布:wi.cap网络嗅探汉化版 编辑:程序博客网 时间:2024/05/15 14:53
A.B签到题,但是都没有1a。
总结教训:
1.头文件忘了写
从此27行头文件时刻准备着。
<span style="font-size:14px;"><span style="font-size:18px;">#include<iostream>#include <vector>#include <list>#include <map>#include <set>#include <deque>#include <queue>#include <stack>#include <bitset>#include <algorithm>#include <functional>#include <numeric>#include <utility>#include <sstream>#include <iostream>#include <iomanip>#include <cstdio>#include <cmath>#include <cstdlib>#include <cctype>#include <string>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <ctime>#include <climits></span></span>
2.总结的规律有问题,就是本质的算法有问题,碰巧举了两个相同奇葩规律的例子。
总结规律的时候至少用三组数据好吗?!三组!而且不要用极端的例子。
3.scanf读取的时候lld读int了。总是喜欢用long long 又对int不离不弃。
unsigned int 0~4294967295 (10位)
int 2147483648~2147483647 (10位)
long long的最大值:9223372036854775807 (19位)
long long的最小值:-9223372036854775808 (19位)
unsigned long long的最大值:18446744073709551615 (20位)
---------------------------------接下来是def题解(我的目标是:谁都看得懂!)-----------------------------------------------------------------------------
C、学姐的学弟(话说这些题目真是要把学姐玩坏了)
题意:给个测试组数,给个n,给一堆x,y都是整数的坐标作为圆心,半径为1,求总覆盖面积。
输入样例
121 12 1
输出样例
5.05482
思路:
看似很鸡杂,其实想一想就懂了,鄙视自己的畏惧心理。
1.画一张直角坐标的网格图出来,对每个矩形分情况讨论。有以下三种。
这个时候,小好奇就要问第二幅图是怎么算出来的了,算法如下:
S=等边三角形+2个小扇形。
2.总结一下:
情况一:一个方格内两条边被标记(蓝蓝的就是标记);
情况二:三条; 情况三:四条;
3.对每一个小方格,记录上下左右4条中一共几条边边被标记,然后就知道这个小方格算面积时用哪种情况的面积。
4.遍历一遍所有的方格,计算不同情况下面积之和。
代码我就不贴了,我看别人博客的时候都会很认真的研究别人的代码,
我这种一个变量名长长长长10个字母的代码风格就不要误人子弟了。。。。。
D. BLOCKS
题意:给一幅n*m图,输出’#‘构成的矩形个数,要是有一个不是矩形,那就满盘皆输。
输入样例
6 8.....#.###.....###.....#.......##......##..#...#6 8.....#.###.....####...##.......###.....##..#...#
输出样例
There are 5 ships.So Sad
思路:
同样看似很沥捞,其实想一想就懂了,鄙视自己的畏惧心理。
不过这个方法是大神教的,我觉得炒鸡好用又容易理解!赞一个~
1.先在图的周围加上一圈“..........................................”
2.遍历整幅图,对于每个matrix【i】【j】搜他的左上,上,左和他自己,在这四个格子里面,如果有三个‘#’,就悲剧了.
对每个[i][j]搜与之对应的A,B,C;
3.如果没有悲剧发生,那就好办了。找有几个((自己是“#”)&&(上方||左方是“.”))的块就行了。
若matrix[i][j]是‘#’,而且B是‘.',或者C是'.',那就矩形个数+1;
E. 数的关系
题意:用关系“<”和“=”将N个数依序排列时有几种。
输入样例
3
输出样例
13
思路:
1.首先不能缺掉情况,比如我就少算了四个数字时两个等号的情况。
2.用动态规划(dp),从以前的状态推出现在的状态,状态转移方程是:
for(int i=1;i<=100;i++) for(int j=1;j<=100;j++) { dp[i+1][j]+=dp[i][j]*j; dp[i+1][j+1]+=dp[i][j]*(j+1); }/*解释一下,这里的i表示有几个数字,j表示总的<的数目-1。比如i=4,[4][1]=1表示全用等号链接有一种方法,[4][2]=14表示有两个等号其余用大于或小于的链接有14种!!!!我就是这里算错了!!!!!!谨记!!!![4][3]=36表示只有一个等号。[4][4]=24表示没有等号*/
3.毫无疑问,肯定要用大数。贴一个大神师傅给我的大数模板。
#include<cstdio>#include<iostream>using namespace std;const int maxn = 200;struct bign{ int len, s[maxn]; bign() { memset(s, 0, sizeof(s)); len = 1; } bign(int num) { *this = num; } bign(const char* num) { *this = num; } bign operator = (int num) { char s[maxn]; sprintf(s, "%d", num); *this = s; return *this; } bign operator = (const char* num) { len = strlen(num); for(int i = 0; i < len; i++) s[i] = num[len-i-1] - '0'; return *this; } string str() const { string res = ""; for(int i = 0; i < len; i++) res = (char)(s[i] + '0') + res; if(res == "") res = "0"; return res; } bign operator + (const bign& b) const{ bign c; c.len = 0; for(int i = 0, g = 0; g || i < max(len, b.len); i++) { int x = g; if(i < len) x += s[i]; if(i < b.len) x += b.s[i]; c.s[c.len++] = x % 10; g = x / 10; } return c; } void clean() { while(len > 1 && !s[len-1]) len--; } bign operator * (const bign& b) { bign c; c.len = len + b.len; for(int i = 0; i < len; i++) for(int j = 0; j < b.len; j++) c.s[i+j] += s[i] * b.s[j]; for(int i = 0; i < c.len-1; i++){ c.s[i+1] += c.s[i] / 10; c.s[i] %= 10; } c.clean(); return c; } bign operator - (const bign& b) { bign c; c.len = 0; for(int i = 0, g = 0; i < len; i++) { int x = s[i] - g; if(i < b.len) x -= b.s[i]; if(x >= 0) g = 0; else { g = 1; x += 10; } c.s[c.len++] = x; } c.clean(); return c; } bool operator < (const bign& b) const{ if(len != b.len) return len < b.len; for(int i = len-1; i >= 0; i--) if(s[i] != b.s[i]) return s[i] < b.s[i]; return false; } bool operator > (const bign& b) const{ return b < *this; } bool operator <= (const bign& b) { return !(b > *this); } bool operator == (const bign& b) { return !(b < *this) && !(*this < b); } bign operator += (const bign& b) { *this = *this + b; return *this; }};istream& operator >> (istream &in, bign& x) { string s; in >> s; x = s.c_str(); return in;}ostream& operator << (ostream &out, const bign& x) { out << x.str(); return out;}int main() { bign a; cin >> a; a += "123456789123456789000000000"; cout << a*2 << endl; return 0;}
写完啦~
- 7.14-2014新生暑假个人排位赛01
- BUPT 2014新生暑假个人排位赛01
- 【总结】2014新生暑假个人排位赛01
- 2014新生暑假个人排位赛01
- 2014新生暑假个人排位赛01 B. 学姐去学车
- 2014新生暑假个人排位赛01 D. BLOCKS
- 2014新生暑假个人排位赛01 E. 数的关系
- BUPT 2014新生暑假个人排位赛02
- 【总结】2014新生暑假个人排位赛03
- 【总结】2014新生暑假个人排位赛02
- BUPT 2014新生暑假个人排位赛03
- 7.16-2014新生暑假个人排位赛02
- 7.18-2014新生暑假个人排位赛03
- BUPT 2014新生暑假个人排位赛04
- 7.21-2014新生暑假个人排位赛04
- 7.23-2014新生暑假个人排位赛05
- BUPT 2014新生暑假个人排位赛05
- 2014新生暑假个人排位赛02
- 通向从容之道——Getting things done读书笔记
- Linux(CentOS)下,设置NAT,访问内网服务器
- 远离压力,提高效率——Getting things done读书笔记
- Maximum Depth of Binary Tree
- libGDX 模块概览
- 7.14-2014新生暑假个人排位赛01
- apt-get
- Git远程操作详解
- 让Apache Shiro保护你的应用
- 定义一个整数N,不用本地变量和循环,输入N,依次判断2N,4N,8N...,一旦大于5000,则倒序输出小于5000的那些数(...,8N,4N,2N,N)
- 黑马程序员_方法、参数、返回值及冒泡排序
- Same Tree
- js 大小写 小括号大括号 定义函数 调用函数 递归!!!
- 调整数组顺序使奇数位于偶数前面