自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(41)
  • 收藏
  • 关注

原创 智能合约漏洞检测工具Pluto环境配置

Pluto工具环境

2023-02-10 22:42:12 731

原创 c++文件读取一行数据

#include<iostream>#include<fstream>using namespace std;int main() { ifstream fin("retail.dat"); string temp; char buf[1000]; //用于截取子字符串的指针 char* p; //缓冲区读入一行 while (fin.getline(buf, 1000)) { //第一次将缓冲区中的字符串用空格分隔,并返回第一个子串 p = strtok

2021-04-12 10:01:34 3730 2

原创 C++表格类

控制台打表输出

2021-04-01 16:06:31 2907 1

原创 php文件操作(1)

file()函数功能 把整个文件读入一个数组中以.txt为例$f = file('name.txt');文件内容:数组内容:数组中每个元素的结尾是有一个\n的所以该文件数组等价于如下array(0 => "aaa\n", 1 => "bbb\n", 2 => "ccc\n", 3 => 'ddd');fopen()函数功能 以指定模式打开指定文件PS:刚开始所有文件只能用读方式打开,后来才知道要给予文件夹操作权限,777表示所有权限sudo ch

2021-02-28 11:09:07 78

原创 (C语言)最小生成树prim算法

最小生成树prim算法的思路总共从n个点中找到n-1条最短路径,所以总循环n-1次{进行n次循环,目的:遍历从起始点到达各个未访问点的距离,取一个最短的把这个最短的路径加到总路径中再进行循环:新增的节点到达某一个未访问点比从源点更近的话,更新源点到此点的距离(dis数组刚开始用于存放源点到达各点的距离,随后更新后表示的是整个网到达各点的距离)注意:要有一个数组标记节点访问情况,如果一个节点被标记了就不能再访问它,否则就会形成一个环,一个环必有一个多余的边。#include<stdio.

2021-02-27 19:05:10 377

原创 (C语言)迪杰斯特拉算法

思路迪杰斯特拉算法和最小生成树算法(prim)很相似就是最后的“松弛”环节不同最小生成树算法(prim)的松弛是将dis更新为生成树到达未标记点的最短距离迪杰斯特拉算法(Dijkstra)的松弛是将dis更新为所选中点到达各点的最短距离prim算法#include<stdio.h>#define inf 999999#define maxnum 50typedef struct MGraph{ int vex[maxnum][maxnum]; int mark[maxnu

2021-02-27 19:04:54 575

原创 (C语言)弗洛伊德最短路径算法

#include<stdio.h>#include<string.h>#include<malloc.h>#define maxnum 50typedef struct MGraph{ int data[maxnum][maxnum]; int num;};int Create(MGraph *G){ scanf("%d",&G->num); for(int i=0;i<G->num;i++){ for(int j=0;j

2021-02-27 19:04:15 203

原创 Linux(CentOS)安装Apache+MySQL+PHP

Linux(CentOS)安装Apache+MySQL+PHP

2021-02-27 16:19:50 151

原创 php与mysql--mysqli(基础)

1.连接数据库直接$link = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db');用变量代替$host = "localhost";$user = "my_user";$password = "my_password";$database = "my_db";$link = mysqli_connect($host, $user, $password, $database);判断是否连接成功if (!$li

2021-02-27 15:29:21 115

原创 C. Sum of Cubes

题目来源一、题目You are given a positive integer x. Check whether the number x is representable as the sum of the cubes of two positive integers.Formally, you need to check if there are two integers a and b (1≤a,b) such that a^3 + b^3=x.For example, if x=35,

2021-02-17 12:58:19 537

原创 D. Permutation Transformation

题目来源一、题目给定一个数组,按如下规律建树:最大元素为根节点,最大元素左边的元素中,最大元素为左子树根节点,最大元素右边的元素中,最大元素为右子树根节点。根节点深度为0,给定数组a,输出每个元素在树中的深度。二、输入The first line contains one integer t (1≤t≤100) — the number of test cases. Then t test cases follow.The first line of each test case cont

2021-02-17 12:46:56 275 2

原创 D. Pythagorean Triples

题目来源一、题目A Pythagorean triple is a triple of integer numbers (a,b,c) such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to a, b and c, respectively. An example of the Pyt

2021-02-16 13:53:22 712

原创 C. Minimum Ties

题目来源一、题目A big football championship will occur soon! n teams will compete in it, and each pair of teams will play exactly one game against each other.There are two possible outcomes of a game:the game may result in a tie, then both teams get 1 point;

2021-02-16 11:24:01 309

原创 B. Cat Cycle

题目来源一、题目Suppose you are living with two cats: A and B. There are n napping spots where both cats usually sleep.Your cats like to sleep and also like all these spots, so they change napping spot each hour cyclically:Cat A changes its napping place in o

2021-02-16 10:32:20 630 2

原创 B - -- - B

来源:https://atcoder.jp/contests/arc112/tasks/arc112_b一、题目Snuke has come to Seisu-ya (integer shop) with an integerB in his hand. In Seiyu-ya, you can exchange your integer for another integer by paying money.More specifically, you can use the following

2021-02-13 22:57:55 570

原创 树状数组

#include<iostream>using namespace std;/* 树状数组 / BIT / Binary Index Tree 求前缀和 / 单点增加*///原数列int a[1000];//树状数组,BIT[i]表示区间a[i - lowbit(i) + 1]至a[i]的和(闭)int BIT[1000];int n;//length of a//lowbit运算,取当前最低位的1及其低位0组成的数,lowbit(1100B) = 100Bint l

2021-02-12 12:39:36 44

原创 字典树(前缀树、单词查找树)

#include<iostream>using namespace std;/* 名称 : 字典树 / 前缀树 / 单词查找树 函数 : 插入 | 查询*/int trie[100][26];//100个节点,trie[i][j]表示:i号节点指向的存储字符('a' + j)的节点编号int nodeCnt = 0;//记录节点编号//插入void insert(char str[], int l) { int cur = 0;//入口始终是0号节点 for (int

2021-02-10 16:23:12 138

原创 并查集c++

#include<iostream>using namespace std;/* 快速判断两个元素是否在同一集合 寻找根节点 / 合并元素*/int fa[1000];//fa[i] 表示i的父节点 当fa[i] == i 时,i是根节点int depth[1000];//depth[i]表示以i为根的数的深度/* 寻找根节点 若根节点不是本身,递归寻找父节点的父节点,直到找到根节点 fa[x] = find(fa[x]) 每次查找压缩整条路径,将途径节点的父节点设为根节

2021-02-08 21:21:02 57

原创 Bowls and Dishes

来源:https://atcoder.jp/contests/abc190/tasks/abc190_c一、题目N个盘子,M个条件,当且仅当Ai和Bi盘子上有球时,条件i被满足。有K个顾客,每个顾客会在盘子Ci或者Di上放一个球。问最多有多少条件被满足?二、输入N MA1 B1...AM BMKC1 D1...Ck Dk三、输出输出答案四、样例input:4 41 21 32 43 431 21 32 3output:2inpu

2021-02-05 10:42:51 244

原创 ROADS

来源:http://bailian.openjudge.cn/practice/1724/一、题目N cities named with numbers 1 … N are connected with one-way roads. Each road has two parameters associated with it : the road length and the toll that needs to be paid for the road (expressed in the numb

2021-02-04 21:24:56 67

原创 二分查找与注意事项

二分查找很简单,但是也有容易被忽视的细节如何防止因写错二分而陷入无尽循环之中呢?#include<iostream>using namespace std;int a[100];//在已排序的a中(从小到大)的闭区间[l, r]中找x的下标,没有找到返回-1int BinarySearch(int a[], int l, int r, int x) { while (l < r) { //右移是向下取整的,那么这里的mid是属于左半区间 //因此,如果写(l + r

2021-01-31 22:15:20 114

原创 Inflation

一、题目You have a statistic of price changes for one product represented as an array of n positive integers p0,p1,…,pn−1, where p0 is the initial price of the product and pi is how the price was increased during the i-th month.Using these price changes you

2021-01-30 17:38:47 331

原创 最大公因数与最小公倍数

最大公因数欧几里得算法 辗转相除int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b);}最小公倍数int lcm(int a, int b) { return a * b / gcd(a, b);}

2021-01-30 09:24:29 104

原创 Nezzar and Lucky Number

一、题目Nezzar’s favorite digit among 1,…,9 is d. He calls a positive integer lucky if d occurs at least once in its decimal representation.Given q integers a1,a2,…,aq, for each 1≤i≤q Nezzar would like to know if ai can be equal to a sum of several (one or

2021-01-29 17:31:33 533

原创 等比数列求和

分治 + 快速幂typedef long long ll;ll fastpow(ll base, ll power, ll mod) { ll ans = 1; while (power > 0) { if (power & 1) ans = ans * base % mod; power >>= 1; base = base * base % mod; } return ans;}/** the sum of : 1 + p^1 + p^2 + ..

2021-01-27 14:33:21 468

原创 简单素数筛

空间换时间#include<iostream>#define RANGE 2000using namespace std;int prime[RANGE];void calc() { for (int i = 0; i < RANGE; i++) prime[i] = 1; for (int i = 2; i < RANGE; i++) { if (prime[i] == 1) { for (int j = i * i; j < RANGE; j +

2021-01-27 11:14:02 67 1

原创 Advertising Agency

一、题目Masha works in an advertising agency. In order to promote the new brand, she wants to conclude contracts with some bloggers. In total, Masha has connections of n different bloggers. Blogger numbered i has ai followers.Since Masha has a limited budge

2021-01-27 10:41:48 279

原创 Ball in Berland

一、题目At the school where Vasya is studying, preparations are underway for the graduation ceremony. One of the planned performances is a ball, which will be attended by pairs of boys and girls.Each class must present two couples to the ball. In Vasya’s cl

2021-01-27 10:21:28 335

原创 二次项系数C(n, k)

利用Cnk = Cn-1k-1 + Cn-1kll dp[2020][2020];ll C(int n, int k){ if (k == 0 || k == n) return 1; if (dp[n][k]) return dp[n][k]; return dp[n][k] = (C(n - 1, k - 1) + C(n - 1, k));}

2021-01-26 17:35:08 1147

原创 C++ Map

C++ Map 用作储存“关键字/值”对Map的声明map<char, int> m1;map<string, long long> m2;...Map的插入map<char, int> m;for (int i = 0; i < 5; i++) { /*相同关键字只会被插入一次,值为第一次插入的值*/ m.insert(make_pair('A' + i, i + 1)); }Map的遍历map<char, int>::

2021-01-25 10:56:56 66

原创 D - Logical Expression

题目来源:https://atcoder.jp/一、题目大意给定N个字符串S1 ,…,Sn ,每个字符串内容为 AND 或 OR 。找到使yn为1的序列(x0 ,…,xn)的数量。1.y0 = x02.对于i >= 1 ,当Si 为AND时,yi =y i-1 ∧xi ;当Si 为OR时,yi =y i-1 ∨xi二、输入第一行,一个正整数 N 。后面N行为S1 …Sn三、输出满足条件的序列数量四、样例样例一input:2ANDORou

2021-01-24 14:33:39 256

原创 利用位运算枚举 费解的开关

费解的开关一、题目你玩过“拉灯”游戏吗?25盏灯排成一个5x5的方形。每一个灯都有一个开关,游戏者可以改变它的状态。每一步,游戏者可以改变某一个灯的状态。游戏者改变一个灯的状态会产生连锁反应:和这个灯上下左右相邻的灯也要相应地改变其状态。我们用数字“1”表示一盏开着的灯,用数字“0”表示关着的灯。下面这种状态1011101101101111000011011在改变了最左上角的灯的状态后将变成:0111111101101111000011011再改变它正中间的灯后状态将变成:

2021-01-23 17:59:45 164 2

原创 签订协议

题目来源:牛客网https://ac.nowcoder.com/一、题目一共有n个国家来到了停战点,在协议停战签订的会场里,环形排布着n个位置, 位置从1开始编号,一直到n号,每个位置上有一个国家。签订停战协议的仪式开始了,停战协议书从1号位置开始传递,一直传递到n号位置, 传到n号时,n号会再传回给1号,从而开始新的一轮传递。 停战协议签订的顺序必须按照国家的战力来排序,战力最高的最先签订停战协议。也就是说,如果停战协议轮到了某个国家,但该国家并不是在场还未签订协议的国家中战力最强的,那么他这轮

2021-01-22 22:53:05 106

原创 照看小猫

一、题目在一个风和日丽的午后,少佐给薇尔莉特伊芙嘉登安排了一个任务。任务大致是这样的,接下来的一周,薇尔莉特需要照顾 N 只小猫咪。为了方便管理这N 只猫咪,薇尔莉特准备给每只猫咪取一个独一无二的名字。取名字要征求猫咪本咪的同意才可以。但这些猫咪都非常有个性,绝不接受很长的名字。现给出每只猫咪所能容忍名字的长度上限。请你为所有猫咪取名字,请问共有多少种不同的方案。名字仅包含小写英文字母。结果可能非常大,所以请将结果对 77797 取模如果无方案,请输出 -1二、输入第一行,一个正整

2021-01-22 22:45:13 181

原创 二叉树基本操作

一、二叉树的数据结构typedef char ElemType;typedef struct BiTNode{ ElemType data; struct BiTNode* lchild; struct BiTNode* rchild;}BiTNode, *BiTree;二、二叉树的建立先序建立二叉树输入格式:abc##d##e##'\n'void CreateBiTree(BiTree *T) { char c; scanf("%c", &c); if (c ==

2021-01-22 17:19:35 113

原创 二进制状态压缩

二进制状态压缩.1二进制状态压缩,是指将一个长度为 m 的 bool 数组用一个 m 位二进制整数表示并存储的方法。//取出整数 n 在二进制表示下的第 k 位 (n >> k) & 1;//取出整数 n 在二进制表示下的第 0 ~ k - 1 位 (后 k 位) n & ((1 << k) - 1)//把整数 n 在二进制表示下的第 k 位 取反 n ^ (1 << k)//对整数 n 在二进制表示下的第 k 位赋值 1 n

2021-01-22 15:16:40 683

原创 快速幂与大数乘法

一、快速幂typedef long long ll;/* (base ^ power) % mod --> [base ^ (power / 2 + power % 2)] % mod --> {[(base * 2) ^ (power / 2)] * [base ^ (power % 2)]} % mod*///快速幂 + 取模ll fastpower(ll base, ll power, ll mod) { if (mod < 2) return 0; ll

2021-01-21 19:33:35 107

原创 归并排序与求逆序数

一、归并排序#include<iostream>using namespace std;int a[100], b[100];/* a原数组,b中间数组,前半段的起始, m前半段的终止,也是两段的中点,e后半段的结束*/void merge(int a[], int l, int m, int e, int b[]) { /* - 假设按从小到大排序 - 现有两段已排序的序列 p1和p2分别指向这两个序列的开头 p指向中间数组的开头,中间数组是用来临时保存排序结

2021-01-20 22:25:20 128

原创 Different Divisors

Positive integer x is called divisor of positive integer y, if y is divisible by x without remainder. For example...

2021-01-20 14:21:57 1429 7

原创 棋盘问题

在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。

2021-01-17 19:30:43 540

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除