
笔记
小二郎123789
这个作者很懒,什么都没留下…
展开
-
1069 The Black Hole of Numbers (20 分) 测试点1234
#include<bits/stdc++.h>using namespace std;int main(){ int a; cin>>a; int big=4,small=6; while(big - small != 6174 && big != small){ string bigstr = to_string(a); while(bigstr.length()!=4){原创 2021-11-11 15:04:14 · 358 阅读 · 0 评论 -
算法题中对于字符操作的总结
#include<string>#include<stdio.h>#include<iostream>using namespace std;int main() { //大小写字符转换 char str[] = "aAdSdSfF"; if (str[8] == '\0') printf("最后一个字符是\0\n"); for (int i = 0; i < strlen(str);i++) { str[i] = toupper(str[原创 2021-11-08 21:37:30 · 122 阅读 · 0 评论 -
Is It a Binary Search Tree采用序列下标的生成方法
#include<bits/stdc++.h>using namespace std;int preorder[1000],postorder[1000];int flag = 1;int less1 = 0;bool isjudge(int prel , int length , int index){ if(less1 == 1){ for(int i = prel+1 ; i < index ; i++){ if(preo原创 2021-11-02 19:01:31 · 99 阅读 · 0 评论 -
Highest Price in Supply Chain(运行超时的问题)
运行超时的原因是:当该树是一条链表的时候,当末端有很多叶子节点的时候,通过叶子找父亲,就需要找好多次解决方法:(1)开辟一个数组,用于存放该节点到根节点(包括叶子节点和根节点的个数),当该数组的值有意义的时候,直接拿来用。采用递归的方式来对该数组进行更新。(2)采用根节点到叶子节点的dfs两种方法的代码如下://第一种方法#include<bits/stdc++.h>using namespace std;int pare[100000] = {-1};bool vis[10原创 2021-11-02 09:59:41 · 134 阅读 · 0 评论 -
1032 Sharing (25 分)
#include<bits/stdc++.h>using namespace std;struct node{ char data; int next; bool flag;}Nodes[100000];int main(){ for(int i = 0 ; i < 100000 ; i++){ Nodes[i].next = -1; Nodes[i].flag = false; } int n , .原创 2021-10-20 19:46:26 · 85 阅读 · 0 评论 -
2021-10-20
#include <iostream>#include<queue>#include<stack>#include<string>#include<map>using namespace std;//首先转换为后缀表达式,然后对后缀表达式进行计算操作struct node { double number; char operators; int flag;};typedef struct node Nod.原创 2021-10-20 19:23:32 · 97 阅读 · 0 评论 -
1013 Battle Over Cities (25 分)
#include<bits/stdc++.h>using namespace std;bool visited[1001] = {false};map<int ,vector<int> > graph;void BFS(int node){ visited[node] = true; for(int i = 0 ; i < graph[node].size() ; i++){ if(!visited[graph[node][原创 2021-10-20 19:15:16 · 74 阅读 · 0 评论 -
1012 The Best Rank (25 分)
#include<bits/stdc++.h>using namespace std;struct student{ string code; int c; int m; int e; double a; map<char , int >mp;}Stu[100000];bool cmp1(struct student s1 , struct student s2){ return s1.c > s2.c;}原创 2021-10-19 21:08:46 · 82 阅读 · 0 评论 -
1011 World Cup Betting (20 分)
#include<bits/stdc++.h>using namespace std;int main(){ pair<double , char> pairs[3]; char infors[3] = {'W','T','L'}; for(int i = 0 ; i < 3 ; i++){ double maxodd = -1.0 ; int index = 0; for(int j = 0 ; j原创 2021-10-19 21:08:16 · 95 阅读 · 0 评论 -
1010 Radix (25 分)
#include<string>#include<iostream>#include<algorithm>using namespace std;long long todemical(string a, int m) { long long total = 0; int number; //进行数值转化的时候,从高数位到低数位要依次乘以radix of the number然后加上下一位的数。从低数位到高数位进行遍历的时候,要分别用进原创 2021-10-19 21:07:45 · 80 阅读 · 0 评论 -
1009 Product of Polynomials (25 分)
#include<bits/stdc++.h>using namespace std;double a[2001] ={0.0};map<int,double> mp1 ;map<int ,double>mp2;int main(){ int n ; int exp ; double cie; cin>>n; while(n--){ cin>>exp >>cie;原创 2021-10-19 21:07:15 · 101 阅读 · 0 评论 -
1008 Elevator (20 分)
#include<bits/stdc++.h>using namespace std;int main(){ int n; int a[101] = {0}; cin>>n; for(int i = 1 ; i <= n ;i++){ cin>>a[i]; } int total = 0; for(int i = 0 ; i < n ; i++){ int data =原创 2021-10-19 21:06:43 · 73 阅读 · 0 评论 -
1006 Sign In and Sign Out (25 分)
#include<bits/stdc++.h>using namespace std;struct person{ string id; string start; string end;}persons[10000];bool startcmp(struct person p1,struct person p2){ return strcmp(p1.start.c_str() , p2.start.c_str())<0;}bool原创 2021-10-19 21:05:38 · 93 阅读 · 0 评论 -
1005 Spell It Right (20 分)
#include<bits/stdc++.h>using namespace std;int main(){ int total = 0; string n; cin>>n; while(n.length()){ total+=(int)n[0]-'0'; n.erase(n.begin()); } string str =to_string(total); map<char,strin原创 2021-10-19 21:04:58 · 75 阅读 · 0 评论 -
1004 Counting Leaves (30 分)
#include<bits/stdc++.h>using namespace std;map<int ,vector<int> > vec;int totalnum[100] = {0};int depth = 0;int maxdepth = 0;void bfs(int root , int depth){ if(depth > maxdepth) maxdepth = depth; int size = vec[ro原创 2021-10-19 21:04:15 · 95 阅读 · 0 评论 -
1002 A+B for Polynomials (25 分)
#include <iostream>#include <cstdio>#include<map>using namespace std;int main(){ map<int,double> data; int k; cin>>k; for(int i=0 ; i < k ; i++){ int e; double c; cin>>e>>c; d原创 2021-10-19 21:03:14 · 81 阅读 · 0 评论 -
pat emergency
在这里插入代码片```#include<cstdio>#include<iostream>#include<cstdlib>using namespace std;typedef struct graph* Graph;struct graph{ int vn , en; struct headtoptr* G;};typedef struct headtoptr* Headtoptr;struct headtoptr{ int原创 2021-10-14 20:53:46 · 119 阅读 · 0 评论 -
pat甲级 a+b format
#include<iostream>#include<cstdio>#include<string>using namespace std;int main(){ int a , b; cin>>a>>b; int result = a+b; string str = to_string(result); if(str[0] == '-') { printf("-");原创 2021-10-14 17:22:40 · 93 阅读 · 0 评论 -
数据库系统概论
数据库系统概论Purpose of Database Systems1.User-dbms-os-db2.数据库的好处:(1)减少信息冗余和不一致(2)减少接入数据的难度,对于每一个新的任务都需要写一个新的程序(3)数据孤立(4)具有完整性约束(5)更新的原子性(如果更新就全部更新,失败全部返回原样)(6)并发性的控制(7)安全性View of Data分为三层:物理层:数据是怎样存储的,数据底层的数据结构逻辑层:数据之间的关系,以及数据库中的那些数据被存储了视图层:描述数据库原创 2021-05-06 23:35:06 · 1694 阅读 · 0 评论 -
原码 补码 反码
基本概念原码:八位最左端代表正负。0代表的是正数,1代表的是负数。反码:如果二进制是正数,则反码与原码一致。如果是负数,最左端的数字不变,其他位置上的数字依次取反。补码:以上步骤跟反码一致。但是是负数的时候,还要加一个1。定点整数取值范围:原码:11111111 – 01111111 -127 到 127反码:10000000 – 01111111 -127 到 127补码:10000000 – 01111111 -128 到 127个数都是2的n次。原码和反码中都有正负零,而补码原创 2020-09-06 19:18:21 · 2150 阅读 · 0 评论