- 博客(6)
- 收藏
- 关注
原创 字符数字转化为数字(c语言实现)
头文件include<stdlib.h> #include<stdio.h> #include<stdlib.h> int dp[1010][1010]; char a[1010]; int b; int main() { scanf("%s",&a); b=atol(a); printf("%d",b); return 0; } 可以将字符输入转化为数字 输入1223(char),可转化为1223(int)型 ...
2022-04-07 16:24:52
4903
2
原创 C - Differential Sorting CodeForces - 1635C (详解)
You are given an arrayaaofnnelements. Your can perform the following operation no more thannntimes: Select three indicesx,y,zx,y,z(1 \leq x < y < z \leq n)(1≤x<y<z≤n)and replacea_xaxwitha_y - a_zay−az. After the operation,|a_x...
2022-02-23 00:45:21
276
原创 关于Avoid Local Maximums CodeForces - 1635B 思路解法(附:解法)
目录 题目如下: 大意: 代码 注意事项: 1.为什么山峰改变为较大的两边较大的数值? 2.数组为什么要变为无穷大? 题目如下: You are given an arrayaaof sizenn. Each element in this array is an integer between11and10^9109. You can perform several operations to this array. Du...
2022-02-21 22:49:05
269
原创 解析Dijkstra求最短路代码思路(详细)
#include<stdio.h> #include<iostream> #include<algorithm> #include <cstring>//函数需要的库 using namespace std; int dist[1005]; bool st[1002]; int w[510][510]; int n,m,x,y,z; int djk() { memset(dist,0x3f,sizeof dist);//初始化记录距离数组.
2022-02-20 18:17:52
432
原创 清空数组 、开三次方产生误差问题 、利用运算法则压缩运算语句(附: 判断子序列代码)
(一)该语句可用于清空数组,头文件为c++的<iostream> memset(a,0,sizeof(a)) (二)使用pow开三次方是利用浮点数使用指数进行开方,在计算时精度损失较大,在数值较大时,会产生精度不够产生误差。 解决办法:使用c++ <math> 库中的cbrt函数, #include<math> int x; cbrt(x); (三)数组的运算比变量的++优先级高,故 a[b[i++]]--; 可实现数组a以a[b[i]]的值进行先
2022-02-19 19:31:33
568
原创 四期(一)二分法及位运算妙用
位运算的妙用 n & 1 == 1;//可判断数据奇偶性 交换变量 x = x ^ y y = x ^ y x = x ^ y \\可以互相交换两个变量 二分法模板 while (m -- ) { int x; scanf("%d", &x); int l = 0, r = n - 1; while (l < r) { int mid ..
2022-02-19 00:56:05
466
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人