ICode9

精准搜索请尝试: 精确搜索
  • QLabel实现鼠标单击,双击2022-08-07 08:31:45

    头文件---LabelRealClick.h #ifndef LABELREALCLICK_H #define LABELREALCLICK_H #include <QLabel> #include <QWidget> #include <QTimer> #include <QMouseEvent> #include <QDebug> #define cout qDebug() << "[" <<

  • 动态规划计算阶乘(阶乘计算最快写法)2022-08-07 01:33:07

    通过数组进行线性递推 用空间换时间是确实比递归要快很多 #include <iostream> #include <cstring> #include <algorithm> #include<cstdio> using namespace std; int main() { long long a[100]={0}; for(int i=0;i<100;i++) { a[i]=i>0?a[i-1]*i

  • 组合数学 求情况2022-08-07 00:00:31

    越狱 https://www.acwing.com/problem/content/1292/ n个房间m个宗教 求2个相同相邻宗教的情况 : 正难则反 ! mn-m*(m-1)(n-1) //所有情况-每个房间信奉不同宗教的情况(第一个房间是m 第二情况必须不同所以是m-1) cout << ( (qmi(m ,n)-m*qmi( m-1 ,n-1 ))%mod+mod)%mod;//快速幂需

  • Dashboard - Codeforces Round #706 (Div. 2) - Codeforces2022-08-06 13:30:49

    Dashboard - Codeforces Round #706 (Div. 2) - Codeforces 1.Problem - A - Codeforces 题意:给定一个字符串何一个k,然后是否可以变成这种形式 $$s=a{_1}+a{_2}+.......+a{_k}+a{_{k+1}}+R(a{_{k-1}})+......+R(a{_{1}})$$ R代表对字符串reverse. 思路:中间字符串可以是任意长度,所

  • Dashboard - Educational Codeforces Round 105 (Rated for Div. 2) - Codeforces2022-08-06 13:00:55

    Dashboard - Educational Codeforces Round 105 (Rated for Div. 2) - Codeforces 1.Problem - A - Codeforces 题意:给定字符串s,只存在ABC三种字母,相同字母只能变成相同的括号,问最后有没有可能形成合法括号。 思路:第一个括号和最后一个括号肯定是确定的,那就已经确定了两个字母,再分

  • Dashboard - Codeforces Global Round 13 - Codeforces2022-08-06 12:45:24

    Dashboard - Codeforces Global Round 13 - Codeforces 1.Problem - B - Codeforces 题意:存在n行1e6+2列,然后会有n个障碍物。可以将障碍物水平移动,和垂直移动。都有对应的消费。你需要从起点(1,1)到终点(n,1e6+2).问最少消费多少。 思路:只要存在两个点之间的y距离是大于1的那这条路肯定

  • C++ 一个交换两数值的神奇代码 有空可以看看2022-08-05 01:32:11

    void swap(int *a, int *b) { *a = (*a&~*b)|(*b&~*a); cout << *a << " " << *b <<endl; *b = (*a&~*b)|(*b&~*a); cout << *a << " " << *b <<endl; *a = (*a&am

  • C++ 数组输出2022-08-01 23:01:47

    C++数组输出 C++中输出数组数据分两种情况:字符型数组和非字符型数组 当定义变量为字符型数组时,采用cout<<数组名; 系统会输出数组中的字符,如 char arr[] = {'1', '2'}; cout << arr << endl ; //输出12 如果想输出字符数组的地址,则需要进行强制转换,如: char arr[] = {'1', '2'}; c

  • 查找算法binary_search2022-07-31 13:31:49

    #include <iostream> #include <vector> #include <algorithm> using namespace std; class Print { public: void operator()(int i) { cout << i << endl; } }; int main() { vector<int> v; for(int i = 0; i

  • 1052 取石子游戏 1 博弈论-普通公式2022-07-30 23:01:34

     分析 要是n 是 k + 1 的倍数,后手只要根据先手,把当前取走的石子个数变成 k + 1就可以了 否则就是先手赢。 #include<bits/stdc++.h> using namespace std; int main() { int n,k; cin>>n>>k; if(n % (k + 1) == 0) { cout<<"2"<<endl; } else {

  • P5318 【深基18.例3】查找文献2022-07-30 16:04:34

    原题地址:P5318 【深基18.例3】查找文献 根据描述和样例 分析如下: 先对 边 u->v 排一个序,满足字典序的需求 dfs和bfs 都要记录当前点是否已经被访问过了,若之前没被访问过,继续dfs或bfs。防止出现重复访问 代码如下: #include<iostream> #include<cstring> #include<vector> #inc

  • 寻找师傅2022-07-30 15:31:49

    【问题描述】   唐僧师徒在取经路上再一次走失了,这一次狡猾的妖怪将唐僧藏入了形如迷宫的洞穴中。已知妖怪洞穴是一个N*N的正方形,其中有一些假山堵路。 输入: 第一行是一个正整数N(2<N<10),后面包含N*N行由θ, 1, 2组成的矩阵,其中0表示可以走,1表示假山,2表示师傅的位置。 输出: 如

  • 算法学习之路 二进制操作2022-07-30 08:31:29

    /* 有关二进制的基本操作分为两类: 1:二进制中 1 的个数; 2:二进制中的lowbit操作;(即二进制数中最后一位 1 的位置) */  //二进制输出:(以10为例) int n;     cin>>n;     for(int k = 3;k >= 0; k--)         cout<<(n >> k & 1);     return 0; // k 的边界值看n的二进制位数

  • 一、HELLO,C++2022-07-29 22:04:51

    hello,大家好,我是你们的新朋友,你们可以叫我小潘~ 或许大家是第一次见到我,也有可能是其他平台过来的,我都要给大家作个自我介绍:我是来自河北石家庄的一名新初一学生。我热爱编程技术,擅长Python、C++和命令行(Windows批处理),目标是信息学竞赛。 我的同学们都说我很幽默,甚至有人说我“不

  • 1017 斐波那契 打表推结论2022-07-29 03:31:06

     分析 打表 发现n 为奇数的时候,结果是-1,n 为偶数的时候结果是1,。由于数据量太大,所以用string存n #include<bits/stdc++.h> using namespace std; const int N = 20; int f[N]; int main() { f[0] = 0,f[1] = 1,f[2] = 1; for(int i = 3;i<N;i++) { f[i] = f[

  • P5657 [CSP-S2019] 格雷码 (找规律)2022-07-28 09:01:53

    观察几个数据,有一种思路:类似于二分,判断每一位应该填1还是0; 1 #include <bits/stdc++.h> 2 //#define loveGsy 3 using namespace std; 4 int n; 5 unsigned long long k, bk; 6 bool flag; 7 8 int main() { 9 #ifdef loveGsy 10 freopen("a.in", "r", std

  • 蔚来杯2022牛客暑期多校训练营12022-07-28 00:33:59

    比赛链接 A 题解 知识点:贪心。 将区间按左端点排序,合并区间,记录所有区间之间断开的长度即可。 时间复杂度 O(nlogn)O(nlog⁡n) 空间复杂度 O(n)O(n) 代码   #include <bits/stdc++.h>   #define ll long long       using namespace std;       struct n

  • list容器反转排序2022-07-28 00:02:45

    #include <iostream> #include <vector> #include <list> #include <algorithm> using namespace std; template<class T> void myPrint(const T &data) { typename T::const_iterator it; for(it = data.begin(); it != data.end(

  • 蔚来杯2022牛客暑期多校训练营12022-07-26 21:33:06

    比赛链接 A 题解 知识点:贪心。 将区间按左端点排序,合并区间,记录所有区间之间断开的长度即可。 时间复杂度 \(O(n\log n)\) 空间复杂度 \(O(n)\) 代码 #include <bits/stdc++.h> #define ll long long using namespace std; struct node { ll l, r; }a[200007]; int main()

  • map2022-07-26 20:32:00

    unordered_map<int,int>a; unordered_map<int ,int>::iterator it; it=a.find(8); if(it==a.end())chu("no");   find找的是前面的键值 unordered_map<int,int>mymap; for ( auto it = mymap.begin(); it != mymap.end(); ++it ) std::cout <

  • 【补】2022.7.22———多校联测【2022年多校冲刺NOIP联训测试4】2022-07-26 12:33:41

    $Write In Front$ 感觉多校联测的题比较水? 成绩综述 $112 / 174$,我菜菜   题 T1 甲国的军队   大水题,先打表找个规律 然后sort一下,按照B[i]与A[i]的差值降序,然后模拟 T1 #include <iostream> #include <iomanip> #include <algorithm> #define GMY (520&1314) #define FBI_O

  • c++类型萃取2022-07-25 18:01:52

    判断两个类型的关系 #include <iostream> #include <type_traits> using std::cout; using std::endl; // is_same is used to judge two data types same or not during compiling void test_is_same() { cout << "test is_same:" << endl;

  • 洛谷 - P10422022-07-24 22:02:59

    原题 题目分析 这道题数据特别大,10000不够。所以我用的是char win[62500]。 每次算完后要清零。 示例代码 #include<iostream> using namespace std; char win[62500]; int main(){ int w,l; for(int i=0;;++i){ cin>>win[i]; if(win[i]=='E')break

  • lamda2022-07-24 01:34:47

    lamda can be as an inline function or a object. [how to understand "lamda", comparing with class] [lamda introducer: pass value or reference ] [spec: mutable,throw, return-type ] format: [] () mutable/throw/->return type { }; 点击查看代码 #inclu

  • C++小数输出保留位数2022-07-23 19:32:49

    #include<iomanip> cout << setiosflags(ios::fixed) << setprecision(2); View Code  

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

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

ICode9版权所有