update
This commit is contained in:
parent
3ee4ba75d5
commit
d13ae78565
@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.15)
|
|||||||
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
add_compile_options(-Wall)
|
add_compile_options(-Wall)
|
||||||
|
include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
118
include/bits/stdc++.h
Normal file
118
include/bits/stdc++.h
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
// C++ includes used for precompiling -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2003-2014 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file stdc++.h
|
||||||
|
* This is an implementation file for a precompiled header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 17.4.1.2 Headers
|
||||||
|
|
||||||
|
// C
|
||||||
|
#ifndef _GLIBCXX_NO_ASSERT
|
||||||
|
#include <cassert>
|
||||||
|
#endif
|
||||||
|
#include <cctype>
|
||||||
|
#include <cerrno>
|
||||||
|
#include <cfloat>
|
||||||
|
#include <ciso646>
|
||||||
|
#include <climits>
|
||||||
|
#include <clocale>
|
||||||
|
#include <cmath>
|
||||||
|
#include <csetjmp>
|
||||||
|
#include <csignal>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
#include <ccomplex>
|
||||||
|
#include <cfenv>
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <cstdbool>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <ctgmath>
|
||||||
|
#include <cwchar>
|
||||||
|
#include <cwctype>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// C++
|
||||||
|
#include <algorithm>
|
||||||
|
#include <bitset>
|
||||||
|
#include <complex>
|
||||||
|
#include <deque>
|
||||||
|
#include <exception>
|
||||||
|
#include <fstream>
|
||||||
|
#include <functional>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <ios>
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <iostream>
|
||||||
|
#include <istream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <limits>
|
||||||
|
#include <list>
|
||||||
|
#include <locale>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <new>
|
||||||
|
#include <numeric>
|
||||||
|
#include <ostream>
|
||||||
|
#include <queue>
|
||||||
|
#include <set>
|
||||||
|
#include <sstream>
|
||||||
|
#include <stack>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <streambuf>
|
||||||
|
#include <string>
|
||||||
|
#include <typeinfo>
|
||||||
|
#include <utility>
|
||||||
|
#include <valarray>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
#include <array>
|
||||||
|
#include <atomic>
|
||||||
|
#include <chrono>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <forward_list>
|
||||||
|
#include <future>
|
||||||
|
#include <initializer_list>
|
||||||
|
#include <mutex>
|
||||||
|
#include <random>
|
||||||
|
#include <ratio>
|
||||||
|
#include <regex>
|
||||||
|
#include <scoped_allocator>
|
||||||
|
#include <system_error>
|
||||||
|
#include <thread>
|
||||||
|
#include <tuple>
|
||||||
|
#include <typeindex>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
37
src/2/P1313.cpp
Normal file
37
src/2/P1313.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using ll = int64_t;
|
||||||
|
|
||||||
|
constexpr ll maxk = 1e3,P=10007;
|
||||||
|
ll C[maxk+5][maxk+5],a,b,k,n,m;
|
||||||
|
|
||||||
|
ll mult(ll const&a,ll const&b){
|
||||||
|
return a*b%P;
|
||||||
|
}
|
||||||
|
|
||||||
|
ll qpow(ll b,ll e){
|
||||||
|
ll r{1};
|
||||||
|
while(e){
|
||||||
|
if(e&1)r=r*b%P;
|
||||||
|
b=b*b%P;
|
||||||
|
e/=2;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PV(v){std::cout<<#v<<" :"<<(v)<<"\n";}
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
std::cin>>a>>b>>k>>n>>m;
|
||||||
|
for(ll i{0};i<=maxk;i++){
|
||||||
|
C[i][0]=C[i][i]=1;
|
||||||
|
for(ll j{1};j<i;j++){
|
||||||
|
C[i][j]=(C[i-1][j]+C[i-1][j-1])%P;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// PV(C[k][m])
|
||||||
|
// PV(qpow(a, n))
|
||||||
|
// PV(qpow(b, m))
|
||||||
|
std::cout<<mult(mult(C[k][m], qpow(a, n)), qpow(b, m))<<'\n';
|
||||||
|
}
|
51
src/2/P4071.cpp
Normal file
51
src/2/P4071.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#include <cmath>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
#include <istream>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
using ll = int64_t;
|
||||||
|
|
||||||
|
constexpr ll maxn = 1e6,p=1e9+7;
|
||||||
|
ll fact[maxn+5],invfact[maxn+5],der[maxn+5];
|
||||||
|
|
||||||
|
ll qpow(ll b,ll e){
|
||||||
|
ll res{1};
|
||||||
|
while(e){
|
||||||
|
if(e&1)res=res*b%p;
|
||||||
|
b = b*b%p;
|
||||||
|
e/=2;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
std::iostream::sync_with_stdio(false),std::cin.tie(nullptr),std::cout.tie(nullptr);
|
||||||
|
|
||||||
|
fact[1]=1;
|
||||||
|
for(ll i{2};i<=maxn;i++){
|
||||||
|
fact[i]=fact[i-1]*i%p;
|
||||||
|
}
|
||||||
|
invfact[maxn] = qpow(fact[maxn], p-2);
|
||||||
|
for(ll i{maxn-1};i>=0;i--){
|
||||||
|
invfact[i]=invfact[i+1]*(i+1)%p;
|
||||||
|
}
|
||||||
|
der[0]=1;
|
||||||
|
der[1]=0;
|
||||||
|
for(ll i{2};i<=maxn;i++){
|
||||||
|
der[i] = (i-1)*((der[i-1]+der[i-2])%p)%p;
|
||||||
|
}
|
||||||
|
|
||||||
|
ll T;
|
||||||
|
std::cin>>T;
|
||||||
|
|
||||||
|
while(T--){
|
||||||
|
const auto [n,m] = []()->std::tuple<ll,ll>{
|
||||||
|
ll n,m;
|
||||||
|
std::cin>>n>>m;
|
||||||
|
return std::make_tuple(n,m);
|
||||||
|
}();
|
||||||
|
const ll C {fact[n]*invfact[m]%p*invfact[n-m]%p};
|
||||||
|
std::cout<<(der[n-m]*C%p)<<'\n';
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,8 @@
|
|||||||
#include <bits/stdc++.h>
|
#include<iostream>
|
||||||
|
#include<algorithm>
|
||||||
|
#include<math.h>
|
||||||
|
#include<cmath>
|
||||||
|
#include <numeric>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
122
src/2/day3.md
122
src/2/day3.md
@ -1,96 +1,70 @@
|
|||||||
<think>
|
> ------思考开始------
|
||||||
好的,我现在要帮用户讲解排列组合的问题。首先,得理解用户的需求是什么。
|
|
||||||
|
|
||||||
之前他问过数学题,所以可能对这方面有兴趣。现在他想深入了解排列和组合的区别以及应用。
|
好,我现在要了解一下DeepSeek公司的两个大语言模型:DeepSeek-14B和DeepSeek-617B。这两个名字中的数字都是以“B”结尾的,我想知道这里的“B”是什么意思,以及它们之间到底有什么不同。
|
||||||
|
|
||||||
我应该先解释什么是排列,包括定义、公式,并举一个具体的例子让用户更容易理解。接着是组合,同样要给出定义、公式和实例,
|
首先,“B”可能代表的是“参数数量”,也就是Billions(十亿)。在机器学习模型中,尤其是神经网络,参数的数量是一个重要的指标,通常决定了模型的复杂度和能力。比如,14B意味着模型有140亿个参数,617B就是6170亿个参数。那这两个数字差别很大,可能会影响
|
||||||
比较两者之间的区别,帮助用户记住它们的不同。
|
模型的表现。
|
||||||
|
|
||||||
然后,可以扩展一些基本的排列组合问题类型,比如重复元素的问题或者分组分配问题,并用实际的例子说明如何解决这些问题。这
|
接下来,我想知道这些参数是怎么影响模型的能力的。一般来说,更多的参数可以让模型学习更复杂的模式和数据中的细节信息,从而提高准确性,特别是在处理复杂任务时表现更好。所以DeepSeek-617B可能会比DeepSeek-14B在各种NLP任务上更强大,比如问答、文本生
|
||||||
样可以让用户不仅了解基础概念,还能应用到实际中去。
|
成、翻译等。
|
||||||
|
|
||||||
最后,总结一下排列组合的应用场景,比如概率、统计和计算机科学中的排序算法,这些都能让用户明白学习这部分知识的重要性。
|
不过,参数越多也有缺点。首先,训练这样的大模型需要更多的计算资源和时间,成本会很高。其次,模型的大小也意味着推理时需要更多的计算资源,可能会影响速度和效率。另外,过大的模型可能会出现过拟合的问题,在数据量不足的情况下表现不佳,或者在小样本
|
||||||
|
任务中不一定比参数少的模型好。
|
||||||
|
|
||||||
|
然后是应用场景的区别。DeepSeek-14B可能更适合资源有限的情况,比如在设备性能较低的环境中运行,或者用于不需要最尖端性能的任务。而DeepSeek-617B则可能在需要高精度和复杂推理的地方发挥作用,比如企业级应用、研究机构的大规模项目等。
|
||||||
|
|
||||||
整体上,语言要尽量口语化,避免过于学术化的表达,让讲解更易于理解。同时,确保每个部分都有清晰的解释和例子,帮助用户一
|
技术细节方面,我还想知道这些模型是如何训练的。是不是使用了相同的架构,只是参数数量不同?还是有其他的区别,比如不同的层结构、注意力机制或者其他组件的变化?另外,训练数据是否有差异也是一个问题,更多的参数可能需要更广泛或多样化的数据来避免过
|
||||||
步步掌握排列组合的知识。
|
拟合和提高泛化能力。
|
||||||
</think>
|
|
||||||
|
|
||||||
好的!排列组合是数学中一个非常重要的领域,常用于解决计数问题。以下是一些基本概念和常见问题类型:
|
市场定位方面,DeepSeek公司可能有不同的产品线,满足不同客户的需求。DeepSeek-14B可能是面向中小企业和个人开发者,而617B则是针对大型企业和研究机构,提供更高性能的服务。
|
||||||
|
|
||||||
---
|
我还想了解一下这两个模型的具体性能对比。比如在基准测试中,它们的表现如何?是否有公开的数据或比较结果可以参考?此外,推理速度和资源消耗也是一个关键点,对于实际部署来说,选择合适的模型不仅要考虑准确率,还要考虑效率和成本。
|
||||||
|
|
||||||
### **1. 排列(Permutation)**
|
另外,考虑到环保和计算资源的使用,参数更多的模型可能对环境影响更大。DeepSeek在设计这些模型时是否采取了绿色计算措施,或者是否有优化策略来减少能源消耗?
|
||||||
**定义:**
|
|
||||||
排列是指从一组元素中按一定的顺序选取若干个元素进行排列的方式数。
|
|
||||||
|
|
||||||
- **公式:**
|
最后,我还想了解这两个模型的应用实例。有没有具体的案例说明它们被用于哪些项目或产品?这可以帮助我更好地理解它们的实际价值和适用场景。
|
||||||
- 如果有 **n** 个不同的元素,从中选出 **k** 个元素的排列数为:
|
|
||||||
$$
|
|
||||||
P(n, k) = \frac{n!}{(n - k)!}
|
|
||||||
$$
|
|
||||||
- 其中,"!" 表示阶乘。
|
|
||||||
|
|
||||||
- **例子:**
|
总结一下,我的问题主要集中在以下几个方面:
|
||||||
- 比如,从3个不同的书(A、B、C)中选出2本排列在书架上,有多少种方法?
|
1. “B”代表什么?
|
||||||
- 排列数为 $ P(3, 2) = \frac{3!}{(3-2)!} = \frac{6}{1} = 6 $ 种。
|
2. 参数数量对模型能力的影响。
|
||||||
- 具体的排列方式是:AB、BA、AC、CA、BC、CB。
|
3. 两个模型在应用场景、性能、资源消耗等方面的区别。
|
||||||
|
4. 训练过程和技术细节的差异。
|
||||||
|
5. 市场定位和使用限制。
|
||||||
|
6. 环境影响和其他实际考虑因素。
|
||||||
|
|
||||||
---
|
通过了解这些,我应该能够比较全面地理解DeepSeek-14B和DeepSeek-617B的区别,以及它们各自适用的情况。
|
||||||
|
> 思考结束
|
||||||
|
|
||||||
### **2. 组合(Combination)**
|
DeepSeek-14B和DeepSeek-617B是DeepSeek公司开发的两个大语言模型,区别主要在于参数数量。以下是它们的主要差异及其影响:
|
||||||
**定义:**
|
|
||||||
组合是指从一组元素中不考虑顺序地选取若干个元素的方式数。
|
|
||||||
|
|
||||||
- **公式:**
|
### 1. 参数数量解释
|
||||||
- 有 **n** 个不同的元素,从中选出 **k** 个元素的组合数为:
|
- **“B”代表Billions(十亿)**:14B表示模型有140亿个参数,而617B则意味着6170亿个参数。
|
||||||
$$
|
|
||||||
C(n, k) = \frac{n!}{k!(n - k)!}
|
|
||||||
$$
|
|
||||||
|
|
||||||
- **例子:**
|
### 2. 模型能力与性能
|
||||||
- 比如,从4个不同的水果(A、B、C、D)中选出2个放在篮子里,有多少种方法?
|
- **DeepSeek-617B**:
|
||||||
- 组合数为 $ C(4, 2) = \frac{4!}{2!(4-2)!} = \frac{24}{2 \times 2} = 6 $ 种。
|
- 更多的参数使其能够学习更复杂的模式和数据细节。
|
||||||
- 具体的组合方式是:AB、AC、AD、BC、BD、CD。
|
- 在处理复杂任务如问答、生成和翻译时表现更优。
|
||||||
|
- 更适合需要高精度和深度推理的应用场景,如企业级应用和研究项目。
|
||||||
|
|
||||||
---
|
- **DeepSeek-14B**:
|
||||||
|
- 参数较少,训练和运行资源需求较低。
|
||||||
|
- 适用于资源有限的环境或不需要最尖端性能的任务,如中小企业和个人开发者使用。
|
||||||
|
|
||||||
### **3. 排列和组合的区别**
|
### 3. 资源消耗与效率
|
||||||
- **排列**:考虑顺序,$ P(n, k) $
|
- 更多参数意味着更高的计算成本、时间投入和能源消耗。617B在推理时需要更多资源,可能影响速度,而14B则更高效。
|
||||||
- **组合**:不考虑顺序,$ C(n, k) $
|
|
||||||
|
|
||||||
例如:
|
### 4. 应用场景
|
||||||
- 从3个元素中选2个排列(AB 和 BA 是不同的),则排列数为6种。
|
- **DeepSeek-14B**适用于资源受限的环境,适合中小任务。
|
||||||
- 从3个元素中选2个组合(AB 和 BA 视为相同),则组合数为1种。
|
- **DeepSeek-617B**用于高要求和复杂应用场景,如大型企业和研究机构。
|
||||||
|
|
||||||
---
|
### 5. 技术细节与训练
|
||||||
|
- 可能使用相同架构,但参数量不同导致复杂度差异。训练数据可能更广泛以支持更多参数的需求。
|
||||||
|
|
||||||
### **4. 常见的排列组合问题类型**
|
### 6. 市场定位与选择
|
||||||
#### (1) 不带重复元素的排列组合
|
- DeepSeek公司提供不同产品线满足不同需求,选择取决于资源、性能和任务要求。
|
||||||
- 直接使用上述公式即可解决。
|
|
||||||
|
|
||||||
#### (2) 带有重复元素的排列组合
|
### 7. 环境影响
|
||||||
- 如果允许元素被多次选择(即可以重复),则计算方式不同。
|
- 更多参数意味着更高的能源消耗,需考虑绿色计算措施和优化策略。
|
||||||
- **排列**:$ P(n, k \text{ with repetition}) = n^k $
|
|
||||||
- **组合**:计算公式较为复杂,一般使用“星与条”方法或生成函数。
|
|
||||||
|
|
||||||
#### (3) 分组问题
|
### 总结
|
||||||
- 将元素分成若干个组,每组有特定数量的元素。
|
DeepSeek-14B和617B的区别主要在于参数数量,影响模型能力、资源需求和应用场景。选择合适的模型需综合考虑性能、效率和实际需求。
|
||||||
- 例子:将10本书分成3组,每组分别有2本、3本和5本。
|
|
||||||
|
|
||||||
#### (4) 排列中的限制条件
|
|
||||||
- 某些元素必须出现在特定位置或不在某些位置。
|
|
||||||
- 例如:“某人必须坐在某个座位上” 或 “某两个人不能相邻”。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### **5. 应用场景**
|
|
||||||
排列组合广泛应用于概率论、统计学、计算机科学(如算法设计和排序问题)以及日常生活中的计数问题。
|
|
||||||
|
|
||||||
- **例子:**
|
|
||||||
- 赌球胜负预测:如果有3场比赛,每场有2种可能的结果(胜或负),总共有 $ 2^3 = 8 $ 种可能的组合。
|
|
||||||
- 遗传密码学:DNA序列中的碱基排列方式可以用排列组合来计算。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
希望这些内容能帮助你理解排列组合的基本概念和应用!如果有具体问题,可以随时问我哦! 😊
|
|
Loading…
Reference in New Issue
Block a user