- 博客(10)
- 资源 (4)
- 收藏
- 关注
原创 BUPT OJ 非平方等式
纯粹数学题。如果无脑直接枚举肯定超时。所以我就超时了。。。后来分析了一下。x^2+s(x)*x-n=0,能拆开成 x*(x+s(x))=n的形式,由于n小于10^18次方,x最大s(x)=162,所以能够得到不等式 sqrt(n)-162剩下的就没啥了/*USER_ID: test#bupt_wcyPROBLEM: 130SUBMISSION_TIME: 2017-01
2017-01-26 21:18:18 770
原创 BUPT OJ 中序遍历树
水题。开始看错,当成按照每个节点代表的字符顺序访问了,后来改完就可以了。#include#include#includeusing namespace std;char func[101];bool relation[100][100]={false};bool visited[100]={false};string result;string temp;void dfs
2017-01-24 15:43:01 872
原创 BUPT OJ 虚数
#include#include#include#includeusing namespace std;class complex{ public: int real; int image; complex(int a=0,int b=0) { real=a; image=b; } };class cmp{ public: bool operator()(
2017-01-23 18:29:37 439
原创 BUPT OJ 寻找宝藏
水题#include#includeusing namespace std;class node{public: int parent; int branches; node() { branches=0; parent=-1; }};const int MAXSIZE = 10000;class tree{public: node point[MAXSIZ
2017-01-23 14:48:16 402
原创 BUPT OJ IP地址
水题#include#includeusing namespace std;inline bool ipstring(string ip){int threes=0;for(int i=0;i{if(ip[i]=='.')threes++;} return threes==3&&ip[ip.size()-1]!='.'&&ip[0]!='.';
2017-01-18 16:12:50 879
原创 BUPT OJ 矩阵幂
水题#include#include#define MAXSIZE 10using namespace std;int k;class matrix{ public: int n; int metric[MAXSIZE][MAXSIZE]; friend ostream& operator<<(ostream&out,matrix &a); friend istream&
2017-01-15 12:36:13 306
原创 BUPT OJ 最小距离查询
用了类似邻接表的结构,一个vector,存放每种字母对应的出现位置,并在插入时排序。用cin超时,scanf通过。。。 怪不得连题目描述里#include#include#include#include#include#include#define MAXSIZE 100001using namespace std;class node{ public:
2017-01-14 23:06:13 375
原创 BUPT OJ 中序遍历序列
水#include#include#includeusing namespace std;int main(){ int t,n,x; cin>>t; while(t--) { vectorBeforeSort; vectorAfterSort; cin>>n; while(n--) { cin>>x; BeforeSor
2017-01-14 16:28:01 343
原创 BUPT OJ 统计节点个数
#include#define MAXSIZE 1000using namespace std;class node{ public: int degree; int parent; int numOfSon; int son[1000]; node() { degree=0; parent=0; numOfSon=0; }};class
2017-01-14 16:10:14 343
原创 BUPT OJ 文件系统
孩子兄弟表示法的多叉树遍历 #include#includeusing namespace std;enum type{file,dir};class node{public: string name; type mytype; node*child; node*brother;//孩子兄弟表示法; };void CreateFile(node*pt,string f
2017-01-13 17:28:29 1127
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人