上一页 1 ··· 8 9 10 11 12 13 14 15 下一页
摘要: 回溯基本思路 问题解析解决回溯问题,实际上就是一个决策树的遍历过程其核心就是for循环里面的递归,在递归调用之前做选择,在递归调用之后撤销选择解决思路1.路径:也就是已经做出的选择2.选择列表:也就是你当前可以做的选择3.结束条件:也就是达决策树底层,无法再做选择的条件 回溯三部曲1.递归函数返回值 阅读全文
posted @ 2022-01-12 17:33 RKevinR 阅读(154) 评论(0) 推荐(0)
摘要: 一.埃氏筛: 埃氏筛就是利用每个数的合数一定不是素数,用空间换取时间,筛选出一定范围内的素数。(合数:就是某个数的倍数*2,*3......这种) 代码实现: 1 #include <stdio.h> 2 #include <stdlib.h> 3 int a[1000000]; 4 int mai 阅读全文
posted @ 2022-01-12 17:27 RKevinR 阅读(50) 评论(0) 推荐(0)
摘要: 1 #include <stdio.h> 2 int main() 3 { 4 int n; 5 int i=1,j; 6 int flag=0; 7 long long int m=1,b; 8 int a[31][10]={0}; 9 int c[10]={0}; 10 a[0][1]=1; 1 阅读全文
posted @ 2022-01-12 17:14 RKevinR 阅读(48) 评论(0) 推荐(0)
摘要: 1 #include "stdio.h" 2 int main() 3 { 4 int target = 7; 5 int nums[6] = {2,3,1,2,4,3}; 6 int numsSize = 6; 7 int point1,point2; 8 long long int sum = 阅读全文
posted @ 2022-01-12 17:13 RKevinR 阅读(254) 评论(0) 推荐(0)
摘要: 证明(m * n) % c = (m % c * n % c) % c 设m = ic + p 设n = jc + q 左式等于((ic + p) * (jc + q)) % c 化简得(ijc^2 + iqc + jpc + pq)% c = pq % c 右式等于((ic + p) % c * 阅读全文
posted @ 2022-01-12 16:52 RKevinR 阅读(81) 评论(0) 推荐(0)
摘要: 一.题目描述: 二.解题思路: 简单快速幂和取余运算 三.代码实现: 1 #include "bits/stdc++.h" 2 using namespace std; 3 int main() 4 { 5 long long int a,b,p; 6 long long int ans = 1; 阅读全文
posted @ 2022-01-12 16:48 RKevinR 阅读(58) 评论(0) 推荐(0)
摘要: 1 #include <stdio.h> 2 struct stack{ 3 int top; 4 int data[100]; 5 }; 6 struct queue{ 7 int head; 8 int tail; 9 int paper[1000]; 10 }; 11 int book[10] 阅读全文
posted @ 2022-01-12 16:44 RKevinR 阅读(150) 评论(0) 推荐(0)
摘要: 1 #include "stdio.h" 2 #include "stdlib.h" 3 #include "string.h" 4 typedef struct Candidates{//创建候选人结构 5 char name[20];//投票人姓名 6 int vote;//投票数 7 stru 阅读全文
posted @ 2022-01-12 16:42 RKevinR 阅读(58) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> typedef struct Node { int val; struct Node *next; }Node,*PNode; typedef struct Stack { struct Node *top; struct 阅读全文
posted @ 2022-01-12 16:40 RKevinR 阅读(48) 评论(0) 推荐(0)
摘要: 1 #include "stdio.h" 2 #include "string.h" 3 int que[100];//定义队列 4 char Ask[100];//定义询问串 5 void pop(int *front,int *top) 6 { 7 if(*front == *top){ 8 p 阅读全文
posted @ 2022-01-12 16:32 RKevinR 阅读(76) 评论(0) 推荐(0)
上一页 1 ··· 8 9 10 11 12 13 14 15 下一页