
c++题解
爱学习的羽
一直在学习
展开
-
CCF201512-3 画图
#includeusing namespace std;#include#includeconst int N=102;char data[N][N];int m,n,q; bool flag[N][N]={false}; int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}}; void fill(int x,int y,char原创 2017-12-02 15:02:26 · 333 阅读 · 0 评论 -
经典的汉诺塔问题
#include<iostream>using namespace std;#include<string>int index = 0;void hanoi(int n,char from,char buffer,char to){ if (n == 1) { cout << from << "->" << to <&原创 2018-03-06 19:23:25 · 403 阅读 · 0 评论 -
A - 敌兵布阵
C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情报局要研究敌人究竟演习什么战术,所以...原创 2018-03-06 20:06:01 · 147 阅读 · 0 评论 -
循环序列
Some DNA sequences exist in circular forms as inthe following figure, which shows a circular sequence“CGAGTCAGCT”, that is, the last symbol “T” in“CGAGTCAGCT” is connected to the first symbol “C”. We ...原创 2018-03-01 12:45:55 · 610 阅读 · 0 评论 -
组合数的生成
采用回朔法 调高程序的效率#include<iostream>#include<cstring>using namespace std;const int N = 1e3;//组合数int num = 0;bool vis[N];int res[N];void solve(int n, int cur){ if (cur>n) { for (int i = 1;...原创 2018-03-09 21:20:38 · 1177 阅读 · 0 评论 -
看病要排队
J - 看病要排队 #include<iostream>using namespace std;#include<queue>#include<string>struct node{ int pri,id; node(int pri,int id){ this->pri=pri; this->id=id; } node(){...原创 2018-03-02 14:14:02 · 201 阅读 · 0 评论 -
丑数
Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ...shows the first 11 ugly numbers.By convention, 1 is included.Write a program to find...原创 2018-03-10 09:38:34 · 210 阅读 · 0 评论 -
素数环
问题描述如图所示,环由n个圆组成。将自然数1,2,...,n分别放入每个圆中,并且两个相邻圆中的数字总和应为素数。注意:第一个圆圈的数量应该始终为1。//素数环问题#include<iostream>#include<cstring>using namespace std;const int N = 20;//判断素数bool isprim[N];bool vis[N];i...原创 2018-03-10 09:55:04 · 438 阅读 · 0 评论 -
敌兵布阵
Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。...转载 2018-03-03 11:38:08 · 241 阅读 · 0 评论 -
201604-3 试题名称: 路径解析
试题编号:201604-3试题名称:路径解析时间限制:1.0s内存限制:256.0MB问题描述:问题描述 在操作系统中,数据通常以文件的形式存储在文件系统中。文件系统一般采用层次化的组织形式,由目录(或者文件夹)和文件构成,形成一棵树的形状。文件有内容,用于存储数据。目录是容器,可包含文件或其他目录。同一个目录下的所有文件和目录的名字各不相同,不同目录下可以有名字相同的文件或目录。 为了指定文...原创 2018-03-22 13:07:35 · 370 阅读 · 0 评论 -
3. 方格填数
如下的10个格子 填入0~9的数字。要求:连续的两个数字不能相邻。 (左右、上下、对角都算相邻) 一共有多少种可能的填数方案? 请填写表示方案数目的整数。 注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。dfs,不过不优化的话有10!边填写边判断#include<iostream>using namespace std;//方格填数 #include<cstr...原创 2018-03-24 09:47:50 · 514 阅读 · 0 评论 -
201703-3 试题名称: Markdown
试题编号:201703-3试题名称:Markdown时间限制:1.0s内存限制:256.0MB问题描述:问题描述 Markdown 是一种很流行的轻量级标记语言(lightweight markup language),广泛用于撰写带格式的文档。例如以下这段文本就是用 Markdown 的语法写成的: 这些用 Markdown 写成的文本,尽管本身是纯文本格式,然而读者可以很容易地看出它的文档...转载 2018-03-24 17:02:58 · 549 阅读 · 0 评论 -
理工大课程设计
目录一.文本文件单词统计... 31.【问题描述】... 32.【问题分析与设计】... 32.1.问题分析... 32.2.概要设计... 33.【功能实现】... 44.【实例测试及运行结果】... 85.【心得体会】... 16二.停车场管理... 171.【问题描述】... 172.【问题分析与设计】... 172.1问题分析... 172.2概要设计... 173.【功能实现】.....原创 2018-07-10 13:19:48 · 1084 阅读 · 0 评论 -
理工大算法实验报告
实验一 递归与分治算法1.1 实验目的与要求1.进一步熟悉C/C++语言的集成开发环境;2.通过本实验加深对递归与分治策略的理解和运用。1.2 实验课时2学时1.3 实验原理分治(Divide-and-Conquer)的思想:一个规模为n的复杂问题的求解,可以划分成若干个规模小于n的子问题,再将子问题的解合并成原问题的解。需要注意的是,分治法使用递归的思想。划分后的每一个子问题与原问题的性...原创 2018-07-10 13:21:35 · 4813 阅读 · 0 评论 -
理工大数值计算方法实验报告
实验名称:方程求根 实验时间:2018.06.12 实验目的和要求: 1.了解方程求根的基本方法、基本原理、误差估计; 2.能够按照工程实际要求,选择适当的算法; 3.通过编写程序,进行算法设计和数值求解。 实验内容和原理: 1. 熟悉使用二分法、牛顿法等方程求根的基本方法、基本原理、误差估计的相关理论。 2. 选择方程求解方法中的两种方法求方程:f(x)=x3+4x2-10=0在[...原创 2018-07-15 19:33:20 · 9944 阅读 · 3 评论 -
谷歌将在AMP页面中移除前缀 保证用户完整体验
谷歌周二宣布,该公司可能会在2018年下半年从Chrome和其它智能手机浏览器的网址中去除AMP签名。能够快速加载并节省数据流量的谷歌AMP网页可以帮助你在早晨上班的路上快速浏览新闻,但同时也会带来一些副作用。你或许已经注意到,AMP网站的网址似乎都带有google.com/amp/的前缀。谷歌解释称,在用户尚未决定是否点击某个网站时,该公司就已经加载了这个页面。正因如此,谷歌必须转载 2018-01-10 11:49:58 · 243 阅读 · 0 评论 -
迪杰斯特拉算法
本周来来介绍指定一个点(源点)到其余各个顶点的最短路径,也叫做“单源最短路径”。例如求下图中的1号顶点到2、3、4、5、6号顶点的最短路径。 与Floyd-Warshall算法一样这里仍然使用二维数组e来存储顶点之间边的关系,初始值如下。 我们还需要用一个一维数组dis来存储1号顶点到其余各个顶点的初始路程,如下。转载 2017-12-27 19:33:36 · 345 阅读 · 0 评论 -
如何让冒泡排序更高效
#includeusing namespace std; const int N=1e3; void maoPao(int data[],int length){ int i=length; int index; while(i>1){ index=1; for(int j=1;j if(data[j]>data[j+1]原创 2017-12-02 15:37:24 · 405 阅读 · 0 评论 -
有向图两顶点间是否存在路径
1. 试基于图的深度优先搜索策略编写一程序,判别以邻接表方式存储的有向图中是否存在有顶点Vi到Vj顶点的路径(i≠j)。 #includeusingnamespacestd;constintN = 100;#includevectorint>data[N];boolflag[N];boolres= true;voiddfs(intstart,inte原创 2017-12-02 15:41:05 · 4135 阅读 · 0 评论 -
sunday 最快的字符串匹配
#include#includeusing namespace std;int sunday(const char *text, const char *find){char map[CHAR_MAX];int i;int text_len = strlen(text);int find_len = strlen(find);if (text_len原创 2017-12-02 15:54:47 · 346 阅读 · 0 评论 -
快速摸幂
#include using namespace std;// 快速模幂计算函数 /*计算n的n次方的末尾数字n是*/int powermod(long long a, int n, int m){long long res = 1;while (n) {if (n & 1) { // n % 2 == 1 re原创 2017-12-02 15:58:58 · 263 阅读 · 0 评论 -
G - IP地址转换
#includeusing namespace std;#includevoid change(int num[],int shu){int j=8;while(shu>0){num[j--]=shu%2;shu/=2;}}int main(){ int one,two,three,four; char c; int data原创 2017-12-03 10:05:29 · 680 阅读 · 0 评论 -
H - 1的个数
#includeusing namespace std;int main(){ int sum=0; int n;cin>>n; int t; while(n--){ cin>>t; sum=0; while(t>0){ if(t%2) ++sum; t/=2; }原创 2017-12-03 10:10:42 · 159 阅读 · 0 评论 -
I - 信号转换
有的时候对一种编码信号需要转换成另一种信号以便于发送或达到其他目的。考虑一种字母信号,只有ABCD四个大写字母组成。要求给定一串字母信号,转为数字信号,转化方式为:A转为数值1,B转为数值2,C表示符号$,D表示换行符。给定一串字母信号,求其数字信号。例如字母信号:AABBCBACADAB转化后数字信号为:1122$21$112Input只有一行数据原创 2017-12-03 10:20:22 · 389 阅读 · 0 评论 -
J - 位操作练习
#includeusing namespace std;#include string change(long int a){ string res=""; char c; while(a>0){ c=a%2+'0'; res.insert(0,1,c); a/=2;} while(res.length() res原创 2017-12-03 10:45:32 · 195 阅读 · 0 评论 -
C - 不吉利日期
#includeusing namespace std;int main(){int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int w; cin>>w; for(int i=1;i int days=0; for(int j=1;j days原创 2017-12-03 11:06:52 · 773 阅读 · 0 评论 -
D - 数字反转
#includeusing namespace std;#includeint main(){string fir,sec;int len;while(getline(cin,sec)){ len=sec.length(); if(sec[0]!='-'&&len>1){ --len; while(sec[len]=='0') --l原创 2017-12-03 11:10:15 · 218 阅读 · 0 评论 -
E - 迷宫问题
定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。Input一个5原创 2017-12-03 11:15:44 · 712 阅读 · 0 评论 -
B - Dungeon Master
ou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south,原创 2017-12-03 11:17:36 · 262 阅读 · 0 评论 -
C - Catch That Cow
Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,0原创 2017-12-03 11:19:23 · 417 阅读 · 0 评论 -
J - Oil Deposits
The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides th原创 2017-12-03 11:22:10 · 180 阅读 · 0 评论 -
1005 大数加法 51nod题解
输入第1行:大数A第2行:大数B(A,B的长度 <= 10000 需注意:A B有可能为负数)输出输出A + B输入样例68932147586468711654886输出样例537643802472此题需要细心。划分为0+0 、两个正数或者两个负数相加、一正一负相加3种情况。用到了比较多的字符串处理#include<io...原创 2019-06-09 11:02:23 · 282 阅读 · 0 评论