自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 几个官方文档链接

几个官网链接

2022-09-23 16:35:44 785

原创 字节-手串

参考:https://blog.csdn.net/weixin_41879093/article/details/104856812 #include <iostream> #include <vector> using namespace std; int main() { int n, m, c; cin >> n >> m >> c; //存储每种颜色对应的珠子索引 vector<vector<int>> n

2022-04-24 16:06:06 207

原创 字节跳动-用户喜好

参考:https://blog.csdn.net/qq_37651325/article/details/107697293 1.暴力解法 import java.util.Scanner; public class Main { public static void main(String[] a){ Scanner sc=new Scanner(System.in); int n=sc.nextInt();//用户数量 int[] arr=new

2022-04-24 15:27:28 376

原创 1552:Doubles

排序 水题 AC代码: //排序 #include <iostream> #include <algorithm> using namespace std; const int N = 16; int num[N]; int main() { int i,j,k,cnt; while (cin >> num[0]) { if (num[0] == -1) break; i = 1,cnt=0; cin >> num[i]; while

2022-03-19 17:03:05 186

原创 1543:Perfect Cubes

枚举 简单 //枚举 #include <iostream> #include <cmath> using namespace std; int main() { int n,i,j,k,m; cin >> n; for (i = 2; i <= n; i++) { for(j=2;j<n;j++) for(k=j;k<n;k++) for (m = k; m < n; m++) { if (pow(i, 3)

2022-03-19 16:46:12 170

原创 1519:Digital Roots

简单 AC代码: //字符串 #include <iostream> #include <string> using namespace std; string calc(string str) { int sum =0; int n = str.size() - 1; for (int i = n; i >= 0; i--) { sum += str[i] - '0'; } return to_string(sum); } int main() { str

2022-03-19 16:34:46 176

原创 1504:Adding Reversed Numbers

模拟 参考:https://blog.csdn.net/MIKASA3/article/details/47699623 //模拟加法 #include <iostream> using namespace std; int reverse(int num) {//反转数字 int ans = 0; while (num) { ans = ans * 10 + num % 10; num /= 10; } return ans; } int main() { int t,

2022-03-19 11:42:57 195

原创 1503:Integer Inquiry

字符串加法 //字符串加法 #include <iostream> #include <cstring> using namespace std; int main() { char a[101]; int sum[102] = { 0 }; int i, j; cin >> a; while (strcmp(a, "0")) { for (i = 0; i < strlen(a); i++) { sum[i] += a[strlen(a) -

2022-03-19 11:01:51 138

原创 1488:TEX Quotes

字符串 简单 getline(cin,str)获取一行行输入 一个字符一个字符地输出 参考:https://blog.csdn.net/WWL919618308/article/details/9124795 //字符串处理 #include <iostream> #include <cstdio> #include <string> using namespace std; int main() { int i,n,count=1; string str;

2022-03-19 10:30:38 200

原创 1469:COURSES

搜索 较难 思路:求解二分图的最大匹配。不难发现,只要匹配可以盖住每门课程,即匹配数与课程数量相等,委员会就可以组成。 参考:https://blog.csdn.net/u014422052/article/details/43603623 //搜索,找到可行解 #include <iostream> #include <cstring> using namespace std; const int N = 305; int p, n,num; int mp[N][N]; int

2022-03-19 09:55:53 174

原创 1458:Common Subsequence

动态规划 题意: 给你两个字符串, 要你求出两个字符串的最长公共子序列长度. 分析: dp[i][j]==x表示A串的前i个字符和B串的前j个字符的最长公共子序列长度为x. 初始化: dp全为0. 状态转移: 最终所求: dp[n][m]. 参考:https://blog.csdn.net/u013480600/article/details/40741333 //动态规划 #include <iostream> #include <cmath> #include <cst

2022-03-19 09:13:58 200

原创 1390:Blocks

动态规划,递归 难 参考:https://blog.csdn.net/PKU_ZZY/article/details/51442591 //动态规划,递归 #include <iostream> #include <cstring> using namespace std; const int N = 201; int t, n, m; int color[N]; int num[N], c[N]; int ans[N][N][N]; //r位右边,与r同色的还有len个情况下

2022-03-18 17:30:10 368

原创 1384:Piggy-Bank

完全背包 解题思路: 这是一个完全背包的问题,多组数据; 给定存钱罐的初始重量和最终重量,给定n种货币的价值,重量; 求恰好满足存钱罐的最终重量的货币总钱数最小值。 若不满足,按题目要求输出“XXX”。 参考:https://blog.csdn.net/weixin_43823808/article/details/104144412 //完全背包 #include <iostream> #include <algorithm> using namespace std; con

2022-03-18 16:54:46 168

原创 1363:Rails

模拟 栈的输入输出 一般 参考:https://blog.csdn.net/su20145104009/article/details/51397833 //模拟栈的输入输出 #include <iostream> #include <stack> using namespace std; const int N = 1003; int num[N];//输出序列 int main() { int n; while (cin >> n && n)

2022-03-18 11:05:24 184

原创 1338:Ugly Numbers

数学,打表 一般 思路: 用三个变量分别标记目前的位置,从1开始,分别乘上2,3,5,得到了新的数字, 再在这些数字中找到最小的一个,如果最小的数字已经在前面的计算中得到了,就让x,y,z分别进行移动。。。。 直到打完这个1500长度的表结束。 参考:https://blog.csdn.net/wikioi_bai/article/details/44037701 AC代码: //打表 #include <iostream> #include <cmath> using name

2022-03-18 10:02:09 312

原创 1331:Multiply

进制转换 简单 AC代码 //进制转换 #include <iostream> #include <cmath> using namespace std; int Min; int calc(int i,int num) {//进制转换 int j=0, ans = 0, tmp; while (num) { tmp = num % 10;//低位 if (Min < tmp)//Min要大于最小数位 Min = tmp; ans += tmp * p

2022-03-18 09:32:31 185

原创 1321:棋盘问题

搜索,dfs 不难 思路: 从第0行开始,需要处理k个棋子,接下来是第一行,k-1个棋子,进行递归搜索(不用做行访问标记) 用vis[]数组,置列访问标记。 k=0时,退回到上一层递归,接着在for循环内寻找新的方案 直到退出第一层递归,遍历完成。 参考:https://blog.csdn.net/coding_sun/article/details/77412738 //搜索,dfs #include <iostream> #include <cstring> using na

2022-03-17 17:11:08 447

原创 1316:Self Numbers

枚举 简单题 //枚举 #include <iostream> #include <cstring> using namespace std; const int N = 10000; bool d[N]; int calc(int n) {//计算n的各位数字之和 int sum = 0; while (n) { sum += n % 10; n /= 10; } return sum; } int main() { int i, tmp; memset(

2022-03-17 10:54:46 397

原创 1298:The Hardest Problem Ever

字符串 简单题 //字符串,密码翻译 #include <iostream> #include <string> using namespace std; int main() { string s1, str, s2; while (cin >> s1) { if (s1 == "ENDOFINPUT") break; getchar();//处理回车 getline(cin,str); cin >> s2; int n = str

2022-03-17 10:25:40 138

原创 1273:Drainage Ditches

2022-03-17 09:24:54 168

原创 1258:Agri-Net

Kruskal 简单 //Kruskal #include <iostream> #include <algorithm> using namespace std; const int maxn = 10010; struct Edge { int from, to, cost; }; bool cmp(Edge a, Edge b) { return a.cost < b.cost; } Edge edge[maxn]; int father[110]; int

2022-03-16 15:57:06 146

原创 1251:丛林中的路

Kruskal,最小生成树 参考:https://blog.csdn.net/shanwenkang/article/details/81021247 //Kruskal #include <iostream> #include <algorithm> using namespace std; const int maxn = 80; struct Edge {//保存边 char from, to; int cost; }; Edge edge[maxn]; char f

2022-03-16 11:18:41 454

原创 1248:Safecracker

暴力枚举 参考:https://blog.csdn.net/Scythe666/article/details/13005067 //枚举 #include <iostream> #include <cstring> #include <algorithm> #include <cmath> using namespace std; char str[15];//输入的字符串 int num[15];//上面字符串对应的数字 void Trans() {

2022-03-16 10:28:49 210

原创 1222:EXTENDED LIGHTS OUT

枚举 解题思路: 从第一行开始,先确定第一行的灭灯策略。 然后从第二行开始分析,如果( i − 1 , j ) 位置是亮的,那么( i , j )位置就必须翻转,只有他能影响到( i − 1 , j )。 反复判断直到最后一行,如果最后一行能全关,就是答案。 参考: https://blog.csdn.net/csyifanZhang/article/details/104560695 https://blog.csdn.net/zwj1452267376/article/details/5067645

2022-03-16 09:26:51 329

原创 1218:THE DRUNK JAILER

模拟 简单题 //模拟 #include <iostream> #include <cstring> using namespace std; const int maxn = 105; int arr[maxn]; int main() { int t,n,cnt; cin >> t; while (t--) { cin >> n; cnt = 0; memset(arr, 0, sizeof(arr));//锁着 for (in

2022-03-15 14:49:08 145

原创 1152:An Easy Problem

数学

2022-03-15 14:36:35 141

原创 1190:生日蛋糕

搜索+剪枝 参考:https://blog.csdn.net/yopilipala/article/details/74999144 //搜索+剪枝 #include <iostream> #include <cmath> using namespace std; int ans = 0x3f3f3f3f;//初始化,很大 int N, M; //剩余层数m,剩余体积leftV,下层半径preR,下层高度preH,当前表面积总和sumS, void dfs(int m, int

2022-03-15 10:33:14 887

原创 1182:食物链

并查集

2022-03-15 09:32:59 139

原创 1166:The Clocks

代码1:纯枚举 不需要单独判断最小方案; 参考:https://blog.csdn.net/Ericipher/article/details/79661439 #include <iostream> #include <cstring> using namespace std; int arr[10], num[10]; void Print(int n,int x) { for (int j = 1; j <= n; j++) printf("%d ", x);

2022-03-14 16:48:58 978

原创 1163:The Triangle

动态规划 解题思路: 用二维数组存放数字三角形:D( r, j) : 第r行第 j 个数字(r,j从1开始算) MaxSum(r, j) : 从D(r,j)到底边的各条路径中,最佳路径的数字之和 问题:求 MaxSum(1,1) D(r, j)出发,下一步只能走D(r+1,j)或者D(r+1, j+1) 参考:https://blog.csdn.net/u014492609/article/details/40510505 //动态规划,递推 #include <iostream> #inc

2022-03-14 15:22:32 980

原创 1131:Octal Fractions

进制转换,模拟字符串除法 题意:   求一个八进制小数的十进制。 分析: 1.求0.756[8] -> ( (6/8 + 5)/8 + 7)/8 [10] 除法过程:如 0.75 5/8的结果需要是整数,那么就5000/8=625 (5加几个0能被8整除就加几个0) 625不能直接加上7,应该加上7000,得到7625; 7625不能被8整除,那么就7625000/8; 输出即可。 参考:https://blog.csdn.net/weixin_30732487/article/det

2022-03-14 11:16:42 585

原创 1088:滑雪

dfs, 记忆化搜索 分析: 求最长的滑雪坡的长度,即求一个最长的下降序列,并且你只能向上下左右走,只能走更低的位置。 我们可以用递归DFS去搜索每一个点能够下降的最长的长度,直到搜到边界返回(边界就是上下左右都不能走,然后自己的值是 1 )。 但是这样搜索会超时,因为我们进行了太多的重复搜索。当这个位置已经被搜过后,那这个点就是此时能够到最低点的最长的坡。当我们下次搜索时,还会进去继续搜索。 记忆化搜索就出现了,我们用一个数组保存我们搜索过的值,就可以避免重复搜索。每当我们再搜索到这里时,我们直接用它已

2022-03-14 09:45:04 171

原创 1068:Parencodings

栈,括号匹配 解题思路: 根据P串还原出括号串:第一个数是4,说明第一个右括号前有4个左括号;第二个数是5,说明到一个右括号后,有5-4个左括号,依次类推,还原出括号串。 用栈来匹配括号:很容易发现,中间包含多少个括号对,可以直接用左括号和右括号的下标来计算。因此,碰到左括号时,把其下标压入栈,碰到右括号时,出栈,由两个下标计算出结果。 参考:https://blog.csdn.net/xp731574722/article/details/76566171 //栈,括号匹配 #include <

2022-03-13 15:34:27 154

原创 1067:取石子游戏

数学 威佐夫博奕 几个概念:奇异局势,黄金分割比例 黄金分割比例判断是不是非奇异局势,公式 ak =[k(1+√5)/2],bk= ak + k 如果两个人都采用正确操作,则面对非奇异局势,先拿者必胜。反之,则后拿者取胜。 参考:https://blog.csdn.net/zzucsliang/article/details/20958853 AC代码: //数学 #include <iostream> #include <cmath> using namespace std;

2022-03-13 15:00:52 3503

原创 1062:昂贵的聘礼

dijkstra, 单源最短路径 建图: 我们可以选取一个超级源点0(即虚拟源点 0 ),每个物品i自身的价格就相当于从顶点0到顶点i连一条边,每个物品i有多个可替代点就相当于从可替代点到顶点i连一条边,最终问题转化为求从顶点0到顶点1的最短路径。 参考:https://blog.csdn.net/qq_42815188/article/details/106162435 AC代码: //dijkstra, 单源最短路径 #include <iostream> #include <cstr

2022-03-13 11:36:15 137

原创 1061:青蛙的约会

模拟 参考:https://blog.csdn.net/zs120197/article/details/52074657 ps:用扩展欧几里得写,效率更高,但不太好理解。 AC代码: //模拟 #include <iostream> #include <algorithm> using namespace std; int main() { int x, y, m, n, L; int X, Y,ans = 0; bool flag = 0; cin >> x

2022-03-13 10:14:53 125

原创 1054:The Troublesome Frog

暴力枚举+剪枝 参考:https://blog.csdn.net/DERITt/article/details/51130372 AC代码: //暴力枚举+剪枝 #include <iostream> #include <algorithm> using namespace std; const int N = 5005; bool vis[N][N]; struct node { int x, y; }p[N]; int cmp(node a, node b) {//从上到下

2022-03-13 09:33:23 563

原创 1050:To the Max

最大子序列和(二维数组) 参考:https://blog.csdn.net/MashiroSky/article/details/52191822 AC: //动态规划,最大子序列和 #include <iostream> #include <climits> using namespace std; int n, a[1010][1010], sum[1010][1010]; int main() { int i, j; cin >> n; for (i = 1;

2022-03-12 16:09:57 212

原创 1047:Round and Round We Go

字符串: AC代码1: //字符串,模拟 #include <iostream> #include <cstring> using namespace std; const int N = 65; char s[N]; int d[100], tmp[100], len; int test(int x) { int i, j; //从新数的第i位开始,循环判断 for (i = x, j = 0; j < len; i = (i + 1) % len, j++) {

2022-03-12 15:44:34 2285

原创 1046 Color Me Less

简单题: AC代码: #include <iostream> #include <climits> #include <cmath> using namespace std; const int N = 20; int R[N], G[N], B[N]; int r, g, b; void dis() {//计算最接近的颜色 float ans = INT_MAX, d; int tr, tg, tb; for (int i = 0; i < 16; i

2022-03-12 14:49:49 83

空空如也

空空如也

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

TA关注的人

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