- 博客(44)
- 收藏
- 关注
原创 python os.cpu_count()显示内核与真实情况不符的问题
os.cpu_count() 显示的是逻辑内核数,而非物理内核数 比如本机配置如下 : 它打印出来就是8,而非4 因此需要使用 import psutil psutil.cpu_count(logical=False) logical=Ture就是显示逻辑内核, logical=False就是显示物理内核 ...
2022-05-09 17:35:43
3748
2
原创 np.asanyarray(....., dtype=“uint8“)带来的错误
需求:我需要把字符串组成的数组转化成整形数组 但是我使用了这个 np.asanyarray(....., dtype="uint8") 函数。 错误:最后数组变成了这样: 原因分析: uint8是指8位,也就是2的八次方:0-255,超过这个范围的会溢出,比如258使用uint8类型之后就变成了2。 正确转换数组为整形数组的办法: 办法一:还是使用这个函数,但是@X@要根据数组的范围进行指定。 np.asanyarray(....., dtype="uint@X@") 方法二..
2022-04-22 20:20:53
1702
原创 centos服务器配置java
需求:配置openjdk11的java step1:登录服务器 step2:配置 先用下面命令查看可安装java版本 yum -y list java* 选择一个安装 sudo yum -y install java-11-openjdk* *这里必须使用sudo不然没有用户权限 step3:验证 java -version 这样就好了 yum安装是不需要配置环境变量的 ...
2022-04-12 17:10:58
1173
原创 图像处理的小问题
1.灰度图像保存 用matplotlib.pyplot保存图片时遇到了将灰度图像保存成彩色图像的问题,原因在于这个库的保存函数会默认保存为彩色图像,如果要保存为灰度必须cmap="gray" plt.imsave('ct0.jpg',img) 也就是这么写 plt.imsave('ct0.jpg',gary,cmap='gray') 当然,也可以用cv2,我推测这个库就是灰度图像自动保存为灰度图像,彩色图像自动保存为彩色图像 cv2.imwrite(spicpath,img) ...
2021-12-01 23:52:50
2030
原创 开发基础小知识【一】
1.集成开发环境(IDE)与编译器:Visual Studio是IDE;VC是编译器。它们对应关系如下: IDE 编译器 VS2017 VC15 VS2015 VC14 VS2013 VC12 VS2012 VC11 VS2010 VC10 VS2008 VC9 VS2005 VC8
2021-11-15 15:16:59
465
原创 我的PAT(甲级)2020年春季考试
7-1 // ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; bool isprime(int num) { if (num <= 1)return false; int sqr = (int)sqrt(num*1.0f); for (int i = 2;
2021-09-08 17:52:58
189
原创 1131 Subway Map
#define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> #include<unordered_map> const int maxn = 100010; const int INF = (1<<30)-1; using namespace std; struct Node { int v; int line; }; vector<Node> a...
2021-08-26 00:41:27
119
原创 PAT A1139 First Contact
#define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> #include<unordered_map> using namespace std; const int maxn = 100010; const int INF = (1<<30)-1; unordered_map<int, vector<int>>adj; bool na...
2021-08-25 20:18:30
539
原创 PAT 1051两种方法(第三种超时)建树DFS与规律
DFS #define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> typedef long long LL; using namespace std; vector <int>pre, mid; struct Node { int data; Node* left; Node* right; Node() { left = NULL; right = ..
2021-08-22 17:27:54
168
原创 PAT A1129 Recommendation System
1129 Recommendation System (25 分) Recommendation system predicts the preference that a user would give to an item. Now you are asked to program a very simple recommendation system that rates the user's preference by the number of times that an item has be
2021-08-16 17:17:00
174
原创 PAT A1047
hash #define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; int N, K; const int maxn = 3000; vector<int> CorseSs[maxn]; int getID(char name[]) { int id = 0; for (int i = 0; i < 3; i++) { .
2021-08-15 22:11:56
131
原创 PAT A1039两种做法
map #define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<cstring> #include<bits/stdc++.h> using namespace std; bool cmp(int a,int b) { return a < b; } int main() { int M, N; scanf("%d %d", &M, &N); map<string
2021-08-15 21:06:32
168
原创 PAT A1045超时代码 与正确做法
#define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; int N,M,L; vector<set<int>>before; set<int>want; vector<int>order; const int maxn = 210; int findinv(int x) { int ind ...
2021-08-13 19:48:58
243
原创 PAT A1003 SPFA
#define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; int N, M, C1, C2; int const maxn = 510; int const INF = 1000000000; int weight[maxn]; struct Node { int v; int d; }; vector<Node> Adj[ma...
2021-08-12 19:42:02
148
原创 PAT A1013BFS与并查集两种做法
BFS #define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; int N,M,K; const int maxn = 1010; const int INF = 1000000; int G[maxn][maxn]; int wu; void BFS(int &liantong,int u,bool isvisited[]) { i.
2021-08-11 16:40:32
117
原创 PAT A1034三种做法 两种并查集与图论
并查集做法(原始版) #define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; int N, K; map<string, string>father; map<string, int> wei; map<string, int> clustwei; typedef struct _node { int cn...
2021-08-10 22:41:59
185
原创 PAT A1074 Reversing Linked List
#define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; typedef struct _node { int data; int last; int next; int id; _node() { last = -1; next = -1; } }Node; int main() { Node nodes[100000];...
2021-08-06 21:11:24
136
原创 PAT A1056
以前的 // A1056.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include<algorithm> #include <iostream> #include<string> #include<queue> #define MAXMUN 10000 using namespace std; int NP, NG; typedef struct _node { int w; int rank; int num
2021-08-06 16:05:26
180
原创 PAT A1051
以前的 #include<stack> #include <iostream> #include<string> #include<queue> using namespace std; int M, N, K; int cnt=1; bool flag = true; void Cando(queue<int>q) { stack<int>s; cnt = 0; int cnum = 1; while(!q.empty.
2021-08-06 13:45:37
150
原创 PAT A1081 Rational Sum 输出判断错误的代码记录
#define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; typedef struct _fraction { long long up; long long down; }fraction; long long gcd(long long a, long long b) { if (b == 0) return a; else...
2021-08-04 19:16:52
129
原创 string str 的scanf、cin输入方法的坑
scanf 1.length()会有问题 2.赋值没问题 3. 大于小于也是正常的 cin输入 1.size 即使是resize之后都没问题
2021-08-04 11:26:06
137
原创 PAT A1101 我的做法以及书上的
#define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; int main() { int N; scanf("%d", &N); vector<long long> nums; vector<long long> aftersort; for (int i = 0; i < N; i++)...
2021-08-03 17:44:46
133
原创 PAT A1029 Median 直接sort与归并两种做法
直接用vector sort的 #define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; int main() { int n1, n2; vector<long long> arr; scanf("%d", &n1); for (int i = 0; i < n1; i++) { int t;...
2021-08-03 14:15:03
115
原创 PAT A1085 Perfect Sequence 二分与two points
二分 #define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; int upperbound(long long a[],int left, int right, long long x) { while (left < right) { int mid = left + (right - left) / 2; if (a[m
2021-08-02 19:07:02
98
原创 PAT A1048 Find Coins 三种方法
贪心 #define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; bool cmp(int a, int b) { return a > b; } int main() { int hashTable[510] = {0}; int nums[100010]; int N,M; scanf("%d %d", &N,&a
2021-08-02 16:52:59
144
原创 PAT A1044
#define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> long long inf = (1LL << 63) - 1; using namespace std; typedef struct MyStruct { int low; int high; int value; }Node; bool cmp(Node a, Node b) { if (a.value !=...
2021-08-02 15:44:22
95
原创 PAT A1010
#define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; int binlowfind(long long arr[], int left, int right, int x) { while (left < right) { int mid = left + (right - left) / 2; if (x <= arr[.
2021-08-02 14:12:23
178
原创 PAT A1084 hash与set两种做法
hash #define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; int getHashNum(char c) { if (c >= 'a'&&c <= 'z') { return int(c - 'a'+'A'); } else { return int(c); } } int main() { .
2021-07-31 15:43:19
80
原创 错误代码记录1095 Cars on Campus (30 分)
#define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<bits/stdc++.h> using namespace std; typedef struct MyStruct { char name[8]; int hh; int mm; int ss; bool isIn; }Car; bool cmp1(Car c1, Car c2) { float t=strcmp(c1.name, c2.name).
2021-07-31 11:13:36
281
原创 p5js码绘笔刷如何嵌入到Web前端(python+Django框架)
一、问题阐述 当我希望能使用p5.js对网页前端进行码绘美化的时候发现不知该如何嵌入,网上也找不到任何教程,在我自己慢慢的摸索下解决了这个问题,希望能对其他需要在前端嵌入p5.js的小伙伴有所帮助,如果有所帮助请点个赞吧。 二、效果展示 将我制作好的网页向下滚动到嵌入p5.js代码的部分,就能够自由地涂鸦啦 三、笔触绘制 整个代码绘制的思路是按照线->笔刷->交互的层次进行层层封装层层丰富。 1.线条的绘制,模仿粗糙的蜡笔效果 实现的效果如下: 每次的颜色波峰...
2021-07-19 02:12:20
587
原创 2021-05-06
#include<cstdio> #include<cstring> #include<bits/stdc++.h> int main() { char str1[80]; char str2[80]; char str3[80]; char str4[80]; scanf("%s",str1); scanf("%s",str2); scanf("%s",str3); scanf("%s",str4); .
2021-05-06 15:01:53
95
原创 1058 A+B in Hogwarts (20 分)
#include<iostream> const int Sickles=29; const int Callon=17*29; int main() { long long a1,a2; int c1,b1,b2,c2; long long p1,p2; scanf("%lld.%d.%d",&a1,&b1,&c1); scanf("%lld.%d.%d",&a2,&b2,&c2); long.
2021-05-05 16:11:48
97
原创 交互实验错误总结
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 目录 文章目录 前言 一、分形实验 二、使用步骤 1.引入库 2.读入数据 总结 前言 主要是些p5js使用上的细节犯错总结 一、分形实验 1.这里要使用单引号而非双引号 let cols = ['#db2763', '#e76b74', '#ff6162', '#80475e', '#e8a04e', '#ffad55']; 2.这样随机出来的才是整数 不然就是小数 int...
2021-04-15 10:14:13
138
转载 B1010题解
#include <cstdio> int main(int argc, char const *argv[]) { int a,b; // 系数a,指数b int count = 0; // 记录共有多少个求导后的非零项 while(scanf("%d %d", &a, &b) != EOF){ if (a != 0 && b != 0) { // 指数不为0且系数不为0 .
2021-03-08 20:35:43
109
原创 1056 Mice and Rice(个人解法与思考、试错、优化过程)
1056Mice and Rice Mice and Riceis the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given map. The goal of each mouse is to eat as much rice as possible in order to become a Fa..
2020-08-10 11:26:52
433
原创 codeup 1918 简单计算器(升级版 包含括号)
题目描述 读入一个只包含 +, -, *, / ,(,)的非负整数计算表达式,计算该表达式的值。 输入 测试输入包含若干测试用例,每个测试用例占一行,每行不超过200个字符,整数和运算符之间用一个空格分隔。没有非法表达式。当一行中只有0时输入结束,相应的结果不要输出。 输出 对每个测试用例输出1行,即该表达式的值,精确到小数点后2位。 样例输入 30 / 90 - 26 + 97 - 5 - 6 - 13 / 88 * 6 + 51 / 29 + 79 * 87 + 57 * 92 0 样
2020-08-09 09:40:47
205
原创 PAT 1051 Pop Sequence
1051Pop Sequence(25分) Given a stack which can keepMnumbers at most. PushNnumbers in the order of 1, 2, 3, ...,Nand pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the stack. For example, ifM...
2020-08-09 09:32:12
144
原创 leetcode岛屿的周长
class Solution {//这个代码是错的 下面是对的 public: int islandPerimeter(vector<vector<int>>& grid) { int number1count = 0; stack<int>S; for (int i = 0; i < grid[0].size(); i++)//这里有错 { for (int j = 0; j < grid.size(); .
2020-07-17 21:48:15
146
原创 Leetcode 两数之和的两种解法
1.解法一暴力 vector<int> twoSum(vector<int>& nums, int target) { vector<int> answer; for(int i=0;i<nums.size();i++) { int aim=target-nums[i]; for(int j=0;j<nums.s
2020-07-17 18:13:31
297
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅