ICode9

精准搜索请尝试: 精确搜索
  • 急性中风2022-08-24 13:01:12

    https://www.acwing.com/problem/content/1583/ 注意: 三维的时候有六个方向。 #include <iostream> #include <cstring> #include <queue> using namespace std; const int M = 1286, N = 128, L = 60; int m, n, l, T; int g[L][M][N]; struct Node { int x, y,

  • 331 树分治 点分治2022-08-23 14:32:19

    视频链接: Luogu P3806 【模板】点分治1 #include<iostream> #include<algorithm> using namespace std; const int N=10005; const int INF=10000005; struct node{int v,w,ne;}e[N<<1]; int idx,h[N]; //加边 int del[N],siz[N],mxs,sum,root;//求根 int dis[N],d[N],c

  • 全排列问题2022-08-23 14:31:13

    全排列问题 思路: 定义一个函数,函数里的变量用于计数。数组用于放数,数组b表示位置标记(为了方便在一个序列中数字不重复)。从1开始深搜,搜索时运用回溯判定即可。然后就是找出口,出口当然是搜索次数 大于n或者等于n + 1的时候,进行输出。 代码如下: #include<iostream> #include<cstdio

  • 推荐系统2022-08-23 14:02:48

    https://www.acwing.com/problem/content/1624/ 写法1 #include <iostream> #include <cstring> #include <algorithm> #include <set> using namespace std; struct node { int value, cnt; bool operator < (const node& t) const

  • C++ 数组作为函数的参数2022-08-23 13:01:30

    1.一个指针在32位操作系统上占4个字节,一个指针在64位操作系统上占8个字节,但是,编译器为了兼容32位操作系统和64位操作系统,所以指针都是4个字节长度。 下面程序中的形参本质上是一个指针,所以无论定义了几个参数都只能传递四个字节。 #include <iostream> #include <windows.h> usin

  • AtCoder-abc265_e Warp2022-08-23 13:00:23

    Warp dp 状态优化 一开始想到的状态为:\(dp[i][x][y]\),第 \(i\) 步走到 \((x,y)\) 的方案数,但是发现状态转移非常难写,原因是坐标计算非常大 后来可以优化一下 \(dp\) 的状态:\(dp[i][j][k]\) 表示第 \(1,2,3\) 个方向走了 \(i,j,k\) 步 的方案数 这样就可以确定好所在的坐标,然后进行

  • 排队等候2022-08-23 12:31:15

    https://www.acwing.com/problem/content/description/1488/ 思路: 依然核心问题是:搞经常模拟的是什么东西,如果这题模拟时间,会很烦,但模拟队列的情况,会简单很多。 #include <iostream> #include <cstring> #include <queue> #include <unordered_map> using namespace std; const

  • 文件IO-getcwd-chdir2022-08-23 11:31:19

    chdir getcwd #include <stdio.h> #include <stdlib.h> #include <unistd.h> #define MAX 512 int main(int argc, char * argv[]) { // 方法一 char path[MAX]; path[0] = '\0'; getcwd(path, sizeof(path)); puts(path);

  • 【ACM】2022.08.21训练赛2022-08-23 10:32:41

    A.连续整数的和【数论】 题目描述 给出一个正整数N,将N写为若干个连续数字和的形式(长度 >= 2)。例如 N = 15,可以写为1 + 2 + 3 + 4 + 5,也可以写为4 + 5 + 6,或7 + 8。如果不能写为若干个连续整数的和,则输出No Solution。 输入 输入1个数N(3 <= N <= 10^9)。 输出 输出连续整数中的

  • 暑假集训82022-08-23 08:33:35

    暑假集训要结束了,快乐的时光总是短暂的,下面是丧心病狂的焚化课时间(人已经焚化了) 最后一场考试又来了一次模拟退役,,体验感极差 暑假结束了, 但是我还是这么菜。。。。。 A. T1 出了个大阴间题 考场一眼装压, 打了个一维的轻松过样例, 然后对拍, 一拍就假 然后发现子问题不优,但是全局可能

  • C语言声明和实现分开例子2022-08-23 06:30:33

    通常将c函数的声明放在头文件,实现放在另一个文件,最后函数被其他文件调用。 一、声明 1 //last.h 2 3 #include <stdio.h> 4 5 void test1(); 二、实现 1 //last.c 2 3 #include "last.h" 4 5 void test1(){ 6 printf("hello world"); 7 } 三、调用 //name.c

  • 文件IO-chdir-getcwd2022-08-23 03:01:23

    getcwd #include <stdio.h> #include <stdlib.h> #include <unistd.h> #define MAX 512 int main(int argc, char * argv[]) { // 方法一 char path[MAX]; path[0] = '\0'; getcwd(path, sizeof(path)); puts(path); /

  • 社会集群2022-08-23 00:03:39

    https://www.acwing.com/problem/content/description/1599/ #include <iostream> #include <cstring> #include <algorithm> #include <vector> using namespace std; const int N = 1010; int n; vector<int> hobby[N]; int p[N]; int cn

  • C++ 黑客攻击系统2022-08-22 23:32:55

    #include <iostream> #include <Windows.h> #include <string> #include <conio.h> //getch使用 #include "hacker.h" using namespace std; #define WIDTH 40 #define HEIGHT 15 void inputPwd(char pwd[], int size) { char c;

  • PAT 计数2022-08-22 21:00:09

    https://www.acwing.com/problem/content/1585/ 状态机的解法 #include <iostream> #include <cstring> using namespace std; const int N = 100010, MOD = 1e9 + 7; int n; char s[N], p[] = " PAT"; int f[N][4]; int main() { cin >> s +

  • 字节跳动2023年机试题2022-08-22 17:32:27

    T1 字节之和 双休在家的凯凯真的是太无聊了,他准备和他家的猫玩一个游戏。 凯凯随手写下一串 01 数列,定义这串数列的子串和为所有长度为2的子串的和。比如数列=010001,有如下长度为 2 的子串: 01 (前导0, =1) 10 00 (前导0,=0) 00 (前导0,=0) 01 (前导0,=1) 所以和为 1+10+0+0+1 = 12 如果要只是

  • HDU2022 第一场2022-08-22 12:30:53

    Backpack 我不打 但我能补题。 明显设\(f_j\)表示容量为j的背包的异或的最大值。但是这样的状态难以进行转移。 考虑设\(f_{j,k}\)表示容量为j异或为k是否可行。 这样状态数为\(2^20\) 但是枚举物品更新达到了\(2^30\) 明显贪心在这个背包类型问题难以解决。考虑优化这个dp。 至少

  • Link with Level Editor I(图上DP,滚动数组)2022-08-22 01:01:38

    题意 一个Level包含了若干个世界,每个世界包含\(m\)个点以及一些有向边,边的数量记为\(l_i\)(无重边和自环)。 玩家一开始站在第一个世界的\(1\)号点上。在每个世界,玩家要么静止在当前点上,要么沿着一条边,走到邻居节点。 然后,玩家将会被传送到下一个世界,并且保持传送前后点的编号不变。

  • Gym-101630C Connections2022-08-21 22:01:42

    Connections 思维 真没看出来 由于给的是强连通图,直接保留从 \(1\) 开始深搜,保证 \(1\) 能访问到其他所有点的,然后反向建图,保证所有点能够到达 \(1\) #include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <vector> using namespace std; const

  • acwing第65场周赛2022-08-21 22:01:29

    1.最大价值 原题链接:https://www.acwing.com/problem/content/4606/ 思路 经典双指针 代码: #include<iostream> #include<algorithm> #include<cstring> using namespace std; int main() { int n; cin >> n; while(n --) { int slen;

  • 4. [2001年NOIP普及组] 最大公约数和最小公倍数问题2022-08-21 21:34:09

    题目链接(码学堂,数据弱) 题目链接(洛谷,数据极强) 摘要: 1.P,Q是正整数(unsigned) 2.要求P,Q以x0为最大公约数,以y0为最小公倍数. 试求:满足条件的所有可能的两个正整数的个数.   分析1: 暴力枚举,看这两个数的最大公约数和最小公倍数是否与题目一样 1 #include<iostream> 2 #include<c

  • 欧拉路径2022-08-21 20:30:08

    https://www.acwing.com/problem/content/1621/ //欧拉图:连通 && 所有点的度数为偶 //半欧拉图:连通 && 只有2个点的度数为奇 其余度数为偶 //非欧拉图:else #include<iostream> #include<algorithm> #include<cstring> using namespace std; const int N=550; bool g[N][N],

  • [NOIP1998 普及组] 三连击2022-08-21 20:04:11

    生成九位一到九的全排列,按题目分割、过滤 #include<iostream> #include<vector> #include<algorithm> bool vis[20]; int queue[50]; int answers[500]; int cnt=0; void search(int x) { for(int i=1;i<=9;i++)//每位数由1到9中的一个 { if(!vis[i]) {

  • [NOIP2001 提高组] 一元三次方程求解2022-08-21 20:03:39

    以0.01精度在[-100,100]枚举根。 #include<iostream> #include<iomanip> int main() { double a,b,c,d; std::cin>>a>>b>>c>>d; for(double x=-100.0;x<=100.0;x+=0.01) { double f=a*x*x*x+b*x*x+c*x+d; if

  • 暑假集训七[One,砖块,数字,甜圈]2022-08-21 20:03:02

    暑假集训七 您总算更新当天的东西了啊。 题面 A.One 典型的约瑟夫问题,\(t<10,n \leq 1e7\)数据范围需要我们用线性算法。 考虑每次去掉一个人后都重新编号,把编号改为 \([0, n)\) 计算,最后剩下的那个数当前的编号一定为 \(0\)。 倒推,考虑一个个复活,草,所以可以推出来上一轮当前点 \(x

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有