Compare commits

..

2 Commits

Author SHA1 Message Date
e2hang
d8b4877ce7 Auto commit at 2026-01-26 17:47:59 2026-01-26 17:48:00 +08:00
e2hang
2846a88e72 Auto commit at 2026-01-26 10:50:01 2026-01-26 10:50:01 +08:00
22 changed files with 1266 additions and 0 deletions

40
cpp/luogu/a.cpp Normal file
View File

@@ -0,0 +1,40 @@
#define _ALLOW_COMPILER_AND_STL_VERSION_MISMATCH
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
class Solution {
public:
unordered_set<vector<int>> result;
vector<int> path;
vector<bool> visited;
void dfs(const vector<int>& nums, vector<int>& path, vector<bool>& visited){
if(path.size() == nums.size()) {
result.insert(path);
return;
}
//use index
for(int i = 0; i < nums.size(); i++){
if(!visited[i]){
path.push_back(nums[i]);
visited[i] = true;
dfs(nums, path, visited);
path.pop_back();
visited[i] = false;
}
}
}
vector<vector<int>> permuteUnique(vector<int>& nums) {
visited.resize(nums.size(), false);
dfs(nums, path, visited);
vector<vector<int>> res(result.begin(), result.end());
return res;
}
};
int main(){
}

65
cpp/luogu/p1118.cpp Normal file
View File

@@ -0,0 +1,65 @@
#include <iostream>
#include <vector>
using namespace std;
int ans = 1e9;
vector<int> path;
vector<bool> visited;
vector<int> result;
bool detected = false;
int c[15][15];
void initc(int n){
for(int i = 0; i < n; i++){
c[i][0] = 1;
for(int j = 1; j <= i; j++){
//C(n, k) = C(n-1, k-1) + C(n-1, k)
c[i][j] = c[i-1][j-1] + c[i-1][j];
}
}
}
void dfs(vector<int>& path, vector<bool>& visited, int sum, int n, int currSum){
if(detected == true) return;
if(currSum > sum) return;
int s = path.size();
if(s == n){
int addup = 0;
for(int i = 0; i < s; i++){
addup += path[i] * c[s - 1][i];
}
//cout << addup << endl;
if(addup == sum) {
//result = result > path ? path : result;
result = path;
detected = true;
}
return;
}
for(int i = 1; i <= n; ++i){
if(!visited[i - 1]){
path.push_back(i);
visited[i - 1] = true;
dfs(path, visited, sum, n, currSum + i * c[n-1][path.size() - 1]);
visited[i - 1] = false;
path.pop_back();
}
}
}
int main(){
int n, sum;
cin >> n >> sum;
visited.resize(n, false);
initc(n);
dfs(path, visited, sum, n, 0);
for(auto& x: result){
cout << x << " ";
}
cout << endl;
return 0;
}

7
cpp/luogu/p1462.cpp Normal file
View File

@@ -0,0 +1,7 @@
#include <iostream>
#include <vector>
using namespace std;
int main(){
return 0;
}

51
cpp/luogu/p1824.cpp Normal file
View File

@@ -0,0 +1,51 @@
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
//int ax[] = {1, 2, 4, 8, 9};
//按照分布,检查是否能够排列即可
/*
1、读入arr, mid
2、按照分布排列找到离mid格最近的槽位插入
*/
int check(const vector<int>& arr, int mid){
if(arr.empty()) return 0;
int cnt = 1;
int n = arr.size();
int dist = 0;
for(int i = 1; i < n; ++i){
dist += arr[i] - arr[i - 1];
if(dist >= mid){
cnt++;
dist = 0;
}
}
return cnt;
}
int main(){
int n = 5, c = 3;
cin >> n >> c;
vector<int> arr(n);
for(int i = 0; i < n; i++){
cin >> arr[i];
//arr[i] = ax[i];
}
sort(arr.begin(), arr.end());
int smin = 0, smax = arr.back() - arr.front();
//range [smin, smax], do mid to this range
int l = smin, r = smax;
int ans = 0;
while(l <= r){
int mid = (l+r)/2;
int cc = check(arr, mid);
if (cc >= c) {
ans = mid;
l = mid + 1;
} else r = mid - 1;
}
cout << ans << endl;
return 0;
}

48
cpp/luogu/p3382.cpp Normal file
View File

@@ -0,0 +1,48 @@
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;
/*
double calc(const vector<double>& func, int x){
int n = func.size();
double ans = 0;
for(int i = 0; i < n; i++){
ans += pow(x, n-i) * func[i];
}
return ans;
}*/
//秦九韶算法
double calc(const vector<double>& func, double x){
double ans = 0;
for(double y: func){
ans = x * ans + y;
}
return ans;
}
int main(){
int n;
double l, r;
n = 3; l = -0.9981; r = 0.5;
//cin >> n >> l >> r;
//任取两个点,把[l, r]分成三段调整l, r的值
vector<double> func(n+1);
func[0] = 1; func[1] = -3; func[2] = -3; func[3] = 1;
/*for(int i = 0; i < n; i++){
}*/
double mid1, mid2;
double ans = 0;
while(r - l > 1e-6){
mid1 = l + (r-l)/3;
mid2 = r - (r-l)/3;
if(calc(func, mid1) > calc(func, mid2)){
r = mid2;
} else if(calc(func, mid1) <= calc(func, mid2)) {
l = mid1;
}
}
cout << fixed << setprecision(8) << l << endl;
return 0;
}

247
git-renew-linux.sh Normal file
View File

@@ -0,0 +1,247 @@
#!/bin/bash
# ============================================
# Git 批量克隆/更新脚本 - Bash 版本
# 适用于 Linux / macOS / Git Bash
# ============================================
# -------------------- 配置区 --------------------
# 父目录路径(存放所有仓库的目录)
PARENT_DIR=".."
# Git 远程仓库用户名
GIT_USERNAME="e2hang"
# Git 远程仓库基础 URL
GIT_BASE_URL="https://huajishe.fun/git"
# 连接方式https 或 ssh
# https: https://huajishe.fun/git/e2hang/<repo>.git
# ssh: git@huajishe.fun:e2hang/<repo>.git
CONNECTION_TYPE="https" # 可选: "https" 或 "ssh"
# SSH 主机(仅当 CONNECTION_TYPE="ssh" 时使用)
SSH_HOST="huajishe.fun"
# -------------------- 仓库列表模式选择 --------------------
# 模式 1: "folders" - 基于父目录下已有的文件夹
# 模式 2: "array" - 基于下面定义的 REPO_LIST 数组
LIST_MODE="folders" # 可选: "folders" 或 "array"
# 仓库列表(仅当 LIST_MODE="array" 时使用)
# 在这里定义你想要同步的仓库名
REPO_LIST=(
"project-one"
"project-two"
"my awesome project"
"another-repo"
)
# -------------------- 脚本主体 --------------------
# 颜色定义
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# 检查父目录是否存在,不存在则创建
if [ ! -d "$PARENT_DIR" ]; then
echo -e "${YELLOW}警告: 父目录 '$PARENT_DIR' 不存在,正在创建...${NC}"
mkdir -p "$PARENT_DIR" || {
echo -e "${RED}错误: 无法创建父目录${NC}"
exit 1
}
fi
# 转换为绝对路径
PARENT_DIR=$(cd "$PARENT_DIR" && pwd)
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}Git 批量同步工具${NC}"
echo -e "${BLUE}========================================${NC}"
echo -e "目标目录: ${CYAN}$PARENT_DIR${NC}"
echo -e "连接方式: ${CYAN}$CONNECTION_TYPE${NC}"
echo -e "列表模式: ${CYAN}$LIST_MODE${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
# 统计变量
total=0
cloned=0
updated=0
skipped=0
failed=0
uptodate=0
# 构建远程仓库 URL
# 参数: $1 = 仓库名
build_remote_url() {
local repo_name="$1"
if [ "$CONNECTION_TYPE" = "ssh" ]; then
echo "git@${SSH_HOST}:${GIT_USERNAME}/${repo_name}.git"
else
echo "${GIT_BASE_URL}/${GIT_USERNAME}/${repo_name}.git"
fi
}
# 处理单个仓库
# 参数: $1 = 仓库名
process_repo() {
local repo_name="$1"
local repo_path="$PARENT_DIR/$repo_name"
local remote_url=$(build_remote_url "$repo_name")
((total++))
echo -e "${BLUE}[$total] 处理仓库: ${CYAN}$repo_name${NC}"
# 情况 1: 目录不存在 - 执行 clone
if [ ! -d "$repo_path" ]; then
echo -e "${YELLOW} → 本地目录不存在,开始克隆...${NC}"
# 进入父目录
cd "$PARENT_DIR" || {
echo -e "${RED} ✗ [ERROR] 无法进入父目录${NC}"
((failed++))
echo ""
return
}
# 执行 clone
if git clone "$remote_url" "$repo_name" 2>&1 | grep -q "Cloning into\|done"; then
echo -e "${GREEN} ✓ [CLONED] 克隆成功${NC}"
((cloned++))
else
echo -e "${RED} ✗ [ERROR] 克隆失败 - 请检查仓库是否存在或网络连接${NC}"
((failed++))
fi
echo ""
return
fi
# 情况 2: 目录存在但不是 Git 仓库 - 跳过并警告
if [ ! -d "$repo_path/.git" ]; then
echo -e "${YELLOW} ⚠ [SKIPPED] 目录存在但不是 Git 仓库${NC}"
((skipped++))
echo ""
return
fi
# 情况 3: 是 Git 仓库 - 执行 pull
echo -e "${YELLOW} → Git 仓库已存在,开始更新...${NC}"
# 进入仓库目录
cd "$repo_path" || {
echo -e "${RED} ✗ [ERROR] 无法进入仓库目录${NC}"
((failed++))
echo ""
return
}
# 获取当前分支
current_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [ -z "$current_branch" ]; then
echo -e "${RED} ✗ [ERROR] 无法确定当前分支${NC}"
((failed++))
echo ""
return
fi
# 保存当前提交哈希(用于判断是否有更新)
before_hash=$(git rev-parse HEAD 2>/dev/null)
# 执行 pull
pull_output=$(git pull origin "$current_branch" 2>&1)
pull_exit_code=$?
if [ $pull_exit_code -eq 0 ]; then
# 获取更新后的提交哈希
after_hash=$(git rev-parse HEAD 2>/dev/null)
if echo "$pull_output" | grep -q "Already up to date\|Already up-to-date"; then
echo -e "${CYAN} ○ [UP-TO-DATE] 已是最新版本${NC}"
((uptodate++))
elif [ "$before_hash" != "$after_hash" ]; then
echo -e "${GREEN} ✓ [UPDATED] 更新成功${NC}"
((updated++))
else
echo -e "${CYAN} ○ [UP-TO-DATE] 已是最新版本${NC}"
((uptodate++))
fi
else
echo -e "${RED} ✗ [ERROR] 更新失败${NC}"
echo -e "${RED} 错误信息: $(echo "$pull_output" | head -n 2)${NC}"
((failed++))
fi
echo ""
}
# -------------------- 主循环 --------------------
# 根据模式获取仓库列表
if [ "$LIST_MODE" = "array" ]; then
echo -e "${CYAN}使用预定义仓库列表 (共 ${#REPO_LIST[@]} 个)${NC}"
echo ""
# 遍历预定义的仓库列表
for repo in "${REPO_LIST[@]}"; do
process_repo "$repo"
done
elif [ "$LIST_MODE" = "folders" ]; then
echo -e "${CYAN}基于现有文件夹列表同步${NC}"
echo ""
# 检查父目录下是否有子文件夹
if [ -z "$(ls -A "$PARENT_DIR" 2>/dev/null)" ]; then
echo -e "${YELLOW}警告: 父目录为空,没有需要处理的仓库${NC}"
echo -e "${YELLOW}提示: 可以将 LIST_MODE 改为 'array' 并定义 REPO_LIST${NC}"
exit 0
fi
# 遍历父目录下的所有一级子目录
for repo_path in "$PARENT_DIR"/*/; do
# 去除末尾的斜杠
repo_path="${repo_path%/}"
# 跳过不是目录的项
if [ ! -d "$repo_path" ]; then
continue
fi
# 获取文件夹名
repo_name=$(basename "$repo_path")
# 处理仓库(这里是 pull 操作)
process_repo "$repo_name"
done
else
echo -e "${RED}错误: 未知的 LIST_MODE '$LIST_MODE'${NC}"
echo -e "${YELLOW}请设置 LIST_MODE 为 'folders' 或 'array'${NC}"
exit 1
fi
# -------------------- 输出统计信息 --------------------
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}同步完成!${NC}"
echo -e "${BLUE}========================================${NC}"
echo -e "总计处理: ${CYAN}$total${NC} 个仓库"
echo ""
echo -e "${GREEN}✓ 克隆成功: $cloned${NC}"
echo -e "${GREEN}✓ 更新成功: $updated${NC}"
echo -e "${CYAN}○ 已是最新: $uptodate${NC}"
echo -e "${YELLOW}⚠ 跳过: $skipped${NC}"
echo -e "${RED}✗ 失败: $failed${NC}"
echo ""
# 如果有失败的,返回非零退出码
if [ $failed -gt 0 ]; then
exit 1
fi
exit 0

238
git-renew-powershell.ps1 Normal file
View File

@@ -0,0 +1,238 @@
# ============================================
# Git 批量克隆/更新脚本 - PowerShell 版本
# 适用于 Windows PowerShell / PowerShell Core
# ============================================
# -------------------- 配置区 --------------------
# 父目录路径(存放所有仓库的目录)
$ParentDir = ".."
# Git 远程仓库用户名
$GitUsername = "e2hang"
# Git 远程仓库基础 URL
$GitBaseUrl = "https://huajishe.fun/git"
# 连接方式https 或 ssh
# https: https://huajishe.fun/git/e2hang/<repo>.git
# ssh: git@huajishe.fun:e2hang/<repo>.git
$ConnectionType = "https" # 可选: "https" 或 "ssh"
# SSH 主机(仅当 ConnectionType="ssh" 时使用)
$SshHost = "huajishe.fun"
# -------------------- 仓库列表模式选择 --------------------
# 模式 1: "folders" - 基于父目录下已有的文件夹
# 模式 2: "array" - 基于下面定义的 RepoList 数组
$ListMode = "folders" # 可选: "folders" 或 "array"
# 仓库列表(仅当 ListMode="array" 时使用)
$RepoList = @(
"project-one",
"project-two",
"my awesome project",
"another-repo"
)
# -------------------- 脚本主体 --------------------
# 检查父目录是否存在,不存在则创建
if (-not (Test-Path -Path $ParentDir)) {
Write-Host "警告: 父目录 '$ParentDir' 不存在,正在创建..." -ForegroundColor Yellow
try {
New-Item -Path $ParentDir -ItemType Directory -Force | Out-Null
}
catch {
Write-Host "错误: 无法创建父目录" -ForegroundColor Red
exit 1
}
}
# 转换为绝对路径
$ParentDir = (Resolve-Path -Path $ParentDir).Path
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Git 批量同步工具" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "目标目录: " -NoNewline
Write-Host $ParentDir -ForegroundColor Cyan
Write-Host "连接方式: " -NoNewline
Write-Host $ConnectionType -ForegroundColor Cyan
Write-Host "列表模式: " -NoNewline
Write-Host $ListMode -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# 统计变量
$total = 0
$cloned = 0
$updated = 0
$skipped = 0
$failed = 0
$uptodate = 0
# 构建远程仓库 URL
function Build-RemoteUrl {
param([string]$RepoName)
if ($ConnectionType -eq "ssh") {
return "git@${SshHost}:${GitUsername}/${RepoName}.git"
}
else {
return "${GitBaseUrl}/${GitUsername}/${RepoName}.git"
}
}
# 处理单个仓库
function Process-Repo {
param([string]$RepoName)
$script:total++
$repoPath = Join-Path -Path $ParentDir -ChildPath $RepoName
$remoteUrl = Build-RemoteUrl -RepoName $RepoName
Write-Host "[$script:total] 处理仓库: " -NoNewline -ForegroundColor Cyan
Write-Host $RepoName -ForegroundColor Cyan
# 情况 1: 目录不存在 - 执行 clone
if (-not (Test-Path -Path $repoPath)) {
Write-Host " → 本地目录不存在,开始克隆..." -ForegroundColor Yellow
# 进入父目录
Push-Location -Path $ParentDir
# 执行 clone
$cloneResult = git clone $remoteUrl $RepoName 2>&1
$cloneSuccess = $LASTEXITCODE -eq 0
Pop-Location
if ($cloneSuccess) {
Write-Host " ✓ [CLONED] 克隆成功" -ForegroundColor Green
$script:cloned++
}
else {
Write-Host " ✗ [ERROR] 克隆失败 - 请检查仓库是否存在或网络连接" -ForegroundColor Red
$script:failed++
}
Write-Host ""
return
}
# 情况 2: 目录存在但不是 Git 仓库 - 跳过并警告
if (-not (Test-Path -Path (Join-Path -Path $repoPath -ChildPath ".git"))) {
Write-Host " ⚠ [SKIPPED] 目录存在但不是 Git 仓库" -ForegroundColor Yellow
$script:skipped++
Write-Host ""
return
}
# 情况 3: 是 Git 仓库 - 执行 pull
Write-Host " → Git 仓库已存在,开始更新..." -ForegroundColor Yellow
# 进入仓库目录
Push-Location -Path $repoPath
# 获取当前分支
$currentBranch = git rev-parse --abbrev-ref HEAD 2>&1
if ([string]::IsNullOrWhiteSpace($currentBranch) -or $LASTEXITCODE -ne 0) {
Write-Host " ✗ [ERROR] 无法确定当前分支" -ForegroundColor Red
$script:failed++
Pop-Location
Write-Host ""
return
}
# 保存当前提交哈希
$beforeHash = git rev-parse HEAD 2>&1
# 执行 pull
$pullResult = git pull origin $currentBranch 2>&1
$pullSuccess = $LASTEXITCODE -eq 0
if ($pullSuccess) {
# 获取更新后的提交哈希
$afterHash = git rev-parse HEAD 2>&1
if ($pullResult -match "Already up.to.date|Already up-to-date") {
Write-Host " ○ [UP-TO-DATE] 已是最新版本" -ForegroundColor Cyan
$script:uptodate++
}
elseif ($beforeHash -ne $afterHash) {
Write-Host " ✓ [UPDATED] 更新成功" -ForegroundColor Green
$script:updated++
}
else {
Write-Host " ○ [UP-TO-DATE] 已是最新版本" -ForegroundColor Cyan
$script:uptodate++
}
}
else {
Write-Host " ✗ [ERROR] 更新失败" -ForegroundColor Red
$errorLines = ($pullResult | Out-String).Split("`n") | Select-Object -First 2
Write-Host " 错误信息: $($errorLines -join ' ')" -ForegroundColor Red
$script:failed++
}
Pop-Location
Write-Host ""
}
# -------------------- 主循环 --------------------
# 根据模式获取仓库列表
if ($ListMode -eq "array") {
Write-Host "使用预定义仓库列表 (共 $($RepoList.Count) 个)" -ForegroundColor Cyan
Write-Host ""
# 遍历预定义的仓库列表
foreach ($repo in $RepoList) {
Process-Repo -RepoName $repo
}
}
elseif ($ListMode -eq "folders") {
Write-Host "基于现有文件夹列表同步" -ForegroundColor Cyan
Write-Host ""
# 获取父目录下的所有子文件夹
$folders = Get-ChildItem -Path $ParentDir -Directory -ErrorAction SilentlyContinue
if ($folders.Count -eq 0) {
Write-Host "警告: 父目录为空,没有需要处理的仓库" -ForegroundColor Yellow
Write-Host "提示: 可以将 ListMode 改为 'array' 并定义 RepoList" -ForegroundColor Yellow
exit 0
}
# 遍历所有文件夹
foreach ($folder in $folders) {
Process-Repo -RepoName $folder.Name
}
}
else {
Write-Host "错误: 未知的 ListMode '$ListMode'" -ForegroundColor Red
Write-Host "请设置 ListMode 为 'folders' 或 'array'" -ForegroundColor Yellow
exit 1
}
# -------------------- 输出统计信息 --------------------
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "同步完成!" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "总计处理: " -NoNewline
Write-Host "$total 个仓库" -ForegroundColor Cyan
Write-Host ""
Write-Host "✓ 克隆成功: $cloned" -ForegroundColor Green
Write-Host "✓ 更新成功: $updated" -ForegroundColor Green
Write-Host "○ 已是最新: $uptodate" -ForegroundColor Cyan
Write-Host "⚠ 跳过: $skipped" -ForegroundColor Yellow
Write-Host "✗ 失败: $failed" -ForegroundColor Red
Write-Host ""
# 如果有失败的,返回非零退出码
if ($failed -gt 0) {
exit 1
}
exit 0

160
git-upload-linux.sh Normal file
View File

@@ -0,0 +1,160 @@
#!/bin/bash
# ============================================
# Git 批量管理脚本 - Bash 版本
# 适用于 Linux 和 Windows Git Bash
# ============================================
# -------------------- 配置区 --------------------
# 父目录路径(支持相对路径和绝对路径)
# 示例:
# ".." -> 上级目录
# "." -> 当前目录
# "./projects" -> 当前目录下的 projects 文件夹
# "../projects" -> 上级目录下的 projects 文件夹
# "/home/user/projects" -> 绝对路径
# "$HOME/projects" -> 用户主目录下的 projects
PARENT_DIR=".."
# Git 远程仓库用户名
GIT_USERNAME="e2hang"
# Git 远程仓库基础 URL
GIT_BASE_URL="https://huajishe.fun/git"
# 默认分支名
DEFAULT_BRANCH="main"
# -------------------- 脚本主体 --------------------
# 颜色定义(可选,增强可读性)
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# 检查父目录是否存在
if [ ! -d "$PARENT_DIR" ]; then
echo -e "${RED}错误: 父目录 '$PARENT_DIR' 不存在${NC}"
exit 1
fi
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}开始处理目录: $PARENT_DIR${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
# 统计变量
total=0
success=0
skipped=0
failed=0
# 遍历父目录下的所有一级子文件夹
for project_path in "$PARENT_DIR"/*/; do
# 去除末尾的斜杠
project_path="${project_path%/}"
# 跳过不是目录的项
if [ ! -d "$project_path" ]; then
continue
fi
# 获取项目文件夹名称
project_name=$(basename "$project_path")
# 计数
((total++))
echo -e "${BLUE}[$total] 处理项目: $project_name${NC}"
# 进入项目目录
cd "$project_path" || {
echo -e "${RED} ✗ 无法进入目录${NC}"
((failed++))
continue
}
# 检查是否为 Git 仓库
if [ ! -d ".git" ]; then
echo -e "${YELLOW} → 初始化 Git 仓库...${NC}"
# 初始化 Git 仓库
if ! git init -b "$DEFAULT_BRANCH" >/dev/null 2>&1; then
# 兼容旧版本 Git
git init >/dev/null 2>&1
git checkout -b "$DEFAULT_BRANCH" >/dev/null 2>&1
fi
# 设置远程仓库
remote_url="$GIT_BASE_URL/$GIT_USERNAME/${project_name}.git"
git remote add origin "$remote_url" >/dev/null 2>&1
echo -e "${GREEN} ✓ 已初始化并设置远程仓库: $remote_url${NC}"
fi
# 检查是否有改动
if git diff --quiet && git diff --cached --quiet; then
# 检查是否有未跟踪的文件
if [ -z "$(git ls-files --others --exclude-standard)" ]; then
echo -e "${YELLOW} ○ 无改动,跳过${NC}"
((skipped++))
echo ""
continue
fi
fi
# 添加所有文件
echo -e "${YELLOW} → 添加文件...${NC}"
git add . >/dev/null 2>&1
# 再次检查是否有需要提交的内容
if git diff --cached --quiet; then
echo -e "${YELLOW} ○ 无需提交的改动,跳过${NC}"
((skipped++))
echo ""
continue
fi
# 生成提交信息(包含当前时间)
commit_msg="Auto commit at $(date '+%Y-%m-%d %H:%M:%S')"
# 提交
echo -e "${YELLOW} → 提交更改...${NC}"
if git commit -m "$commit_msg" >/dev/null 2>&1; then
echo -e "${GREEN} ✓ 提交成功${NC}"
# 推送到远程仓库
echo -e "${YELLOW} → 推送到远程仓库...${NC}"
# 尝试推送,捕获错误
if git push -u origin "$DEFAULT_BRANCH" 2>&1 | grep -q "Everything up-to-date\|Successfully"; then
echo -e "${GREEN} ✓ 推送成功${NC}"
((success++))
else
# 推送失败,尝试普通推送
if git push 2>&1 | grep -q "Everything up-to-date\|Successfully"; then
echo -e "${GREEN} ✓ 推送成功${NC}"
((success++))
else
echo -e "${RED} ✗ 推送失败(可能需要先 pull 或检查远程仓库)${NC}"
((failed++))
fi
fi
else
echo -e "${RED} ✗ 提交失败${NC}"
((failed++))
fi
echo ""
done
# 输出统计信息
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}处理完成!${NC}"
echo -e "${BLUE}========================================${NC}"
echo -e "总计: $total 个项目"
echo -e "${GREEN}成功: $success${NC}"
echo -e "${YELLOW}跳过: $skipped${NC}"
echo -e "${RED}失败: $failed${NC}"
echo ""

167
git-upload-powershell.ps1 Normal file
View File

@@ -0,0 +1,167 @@
# ============================================
# Git 批量管理脚本 - PowerShell 版本
# 适用于 Windows PowerShell 和 PowerShell Core
# ============================================
# -------------------- 配置区 --------------------
# 父目录路径(支持相对路径和绝对路径)
# 示例:
# ".." -> 上级目录
# "." -> 当前目录
# ".\projects" -> 当前目录下的 projects 文件夹
# "..\projects" -> 上级目录下的 projects 文件夹
# "C:\projects" -> 绝对路径
# "$env:USERPROFILE\projects" -> 用户主目录下的 projects
$ParentDir = ".."
# Git 远程仓库用户名
$GitUsername = "e2hang"
# Git 远程仓库基础 URL
$GitBaseUrl = "https://huajishe.fun/git"
# 默认分支名
$DefaultBranch = "main"
# -------------------- 脚本主体 --------------------
# 将相对路径转换为绝对路径
$ParentDir = Resolve-Path -Path $ParentDir -ErrorAction SilentlyContinue
# 检查父目录是否存在
if (-not $ParentDir -or -not (Test-Path -Path $ParentDir -PathType Container)) {
Write-Host "错误: 父目录不存在或无法访问" -ForegroundColor Red
exit 1
}
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "开始处理目录: $ParentDir" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# 统计变量
$total = 0
$success = 0
$skipped = 0
$failed = 0
# 获取所有一级子文件夹
$projects = Get-ChildItem -Path $ParentDir -Directory
foreach ($project in $projects) {
$total++
$projectPath = $project.FullName
$projectName = $project.Name
Write-Host "[$total] 处理项目: $projectName" -ForegroundColor Cyan
# 进入项目目录
try {
Push-Location -Path $projectPath -ErrorAction Stop
}
catch {
Write-Host " ✗ 无法进入目录" -ForegroundColor Red
$failed++
continue
}
# 检查是否为 Git 仓库
if (-not (Test-Path -Path ".git" -PathType Container)) {
Write-Host " → 初始化 Git 仓库..." -ForegroundColor Yellow
# 初始化 Git 仓库
try {
git init -b $DefaultBranch 2>&1 | Out-Null
}
catch {
# 兼容旧版本 Git
git init 2>&1 | Out-Null
git checkout -b $DefaultBranch 2>&1 | Out-Null
}
# 设置远程仓库
$remoteUrl = "$GitBaseUrl/$GitUsername/$projectName.git"
git remote add origin $remoteUrl 2>&1 | Out-Null
Write-Host " ✓ 已初始化并设置远程仓库: $remoteUrl" -ForegroundColor Green
}
# 检查是否有改动
$diffResult = git diff --quiet 2>&1
$diffCachedResult = git diff --cached --quiet 2>&1
$untrackedFiles = git ls-files --others --exclude-standard 2>&1
if ($LASTEXITCODE -eq 0 -and $diffCachedResult -eq $null -and [string]::IsNullOrWhiteSpace($untrackedFiles)) {
Write-Host " ○ 无改动,跳过" -ForegroundColor Yellow
$skipped++
Pop-Location
Write-Host ""
continue
}
# 添加所有文件
Write-Host " → 添加文件..." -ForegroundColor Yellow
git add . 2>&1 | Out-Null
# 再次检查是否有需要提交的内容
git diff --cached --quiet 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host " ○ 无需提交的改动,跳过" -ForegroundColor Yellow
$skipped++
Pop-Location
Write-Host ""
continue
}
# 生成提交信息
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$commitMsg = "Auto commit at $timestamp"
# 提交
Write-Host " → 提交更改..." -ForegroundColor Yellow
$commitResult = git commit -m $commitMsg 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host " ✓ 提交成功" -ForegroundColor Green
# 推送到远程仓库
Write-Host " → 推送到远程仓库..." -ForegroundColor Yellow
# 尝试推送
$pushResult = git push -u origin $DefaultBranch 2>&1
if ($LASTEXITCODE -eq 0 -or $pushResult -match "Everything up-to-date|Successfully") {
Write-Host " ✓ 推送成功" -ForegroundColor Green
$success++
}
else {
# 尝试普通推送
$pushResult = git push 2>&1
if ($LASTEXITCODE -eq 0 -or $pushResult -match "Everything up-to-date|Successfully") {
Write-Host " ✓ 推送成功" -ForegroundColor Green
$success++
}
else {
Write-Host " ✗ 推送失败(可能需要先 pull 或检查远程仓库)" -ForegroundColor Red
$failed++
}
}
}
else {
Write-Host " ✗ 提交失败" -ForegroundColor Red
$failed++
}
# 返回上级目录
Pop-Location
Write-Host ""
}
# 输出统计信息
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "处理完成!" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "总计: $total 个项目"
Write-Host "成功: $success" -ForegroundColor Green
Write-Host "跳过: $skipped" -ForegroundColor Yellow
Write-Host "失败: $failed" -ForegroundColor Red
Write-Host ""

8
python/test/test.py Normal file
View File

@@ -0,0 +1,8 @@
import collections
a = 15
b = 16
c = int(input("Give a integer input"))
x = {a, b, c}
print(a + b + c, x)

View File

@@ -398,3 +398,225 @@ java.nio.file.FileSystemException: D:\Git\workspace\~\.emacs.d\cache\jdtls-works
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-09 15:45:27.712 !ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-09 15:45:27.712
!MESSAGE >> document/signatureHelp !MESSAGE >> document/signatureHelp
!SESSION 2026-01-15 11:27:31.026 -----------------------------------------------
eclipse.buildId=unknown
java.version=25.0.1
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=zh_CN
Command-line arguments: -data ~/.emacs.d/cache/jdtls-workspace
!ENTRY org.eclipse.core.resources 2 10035 2026-01-15 11:27:32.696
!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:34.208
!MESSAGE class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is started
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:34.320
!MESSAGE Main thread is waiting
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:34.337
!MESSAGE >> initialize
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:34.338
!MESSAGE Initializing Java Language Server 1.9.0.202203031534
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:34.353
!MESSAGE Static Commands: []
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:34.353
!MESSAGE Non-Static Commands: [java.edit.organizeImports, java.project.refreshDiagnostics, java.project.import, java.navigate.openTypeHierarchy, java.project.removeFromSourcePath, java.project.listSourcePaths, java.project.resolveStackTraceLocation, java.project.getAll, java.project.isTestFile, java.project.getClasspaths, java.navigate.resolveTypeHierarchy, java.edit.stringFormatting, java.project.getSettings, java.project.updateSourceAttachment, java.project.upgradeGradle, java.project.resolveSourceAttachment, java.project.addToSourcePath]
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:34.355
!MESSAGE Starting org.eclipse.m2e.core
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:34.356
!MESSAGE Started org.eclipse.m2e.core 0ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:34.356
!MESSAGE ProjectRegistryRefreshJob finished 0ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:34.356
!MESSAGE Starting org.eclipse.buildship.core
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:34.368
!MESSAGE Started org.eclipse.buildship.core 12ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:35.893
!MESSAGE LoadingGradleVersionJob finished 1525ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:35.937
!MESSAGE >> initialized
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.210
!MESSAGE Workspace initialized in 315ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.230
!MESSAGE >> initialization job finished
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.231
!MESSAGE >> document/didOpen
!SESSION 2026-01-15 11:27:36.069 -----------------------------------------------
eclipse.buildId=unknown
java.version=25.0.1
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=zh_CN
Command-line arguments: -data ~/.emacs.d/cache/jdtls-workspace
!ENTRY org.eclipse.core.resources 2 10035 2026-01-15 11:27:36.465
!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.487
!MESSAGE Reconciled 1. Took 1 ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.510
!MESSAGE >> document/didOpen
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.522
!MESSAGE begin problem for /Matrix.java
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.522
!MESSAGE 1 problems reported for /Matrix.java
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.524
!MESSAGE Validated 1. Took 26 ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.531
!MESSAGE Reconciled 1. Took 1 ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.555
!MESSAGE >> workspace/didChangeConfiguration
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.561
!MESSAGE >> New configuration: {}
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.572
!MESSAGE begin problem for /Main.java
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.575
!MESSAGE Resource leak: 'input' is never closed is of type UnclosedCloseable
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.576
!MESSAGE 2 problems reported for /Main.java
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.589
!MESSAGE begin problem for /Matrix.java
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.590
!MESSAGE 1 problems reported for /Matrix.java
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.590
!MESSAGE Validated 2. Took 49 ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.637
!MESSAGE >> build jobs finished
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.639
!MESSAGE >> registerWatchers'
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.641
!MESSAGE >> registerFeature 'workspace/didChangeWatchedFiles'
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.642
!MESSAGE >> watchers registered
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.704
!MESSAGE class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is started
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.797
!MESSAGE Main thread is waiting
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.812
!MESSAGE >> initialize
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.813
!MESSAGE Initializing Java Language Server 1.9.0.202203031534
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.827
!MESSAGE Static Commands: []
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.827
!MESSAGE Non-Static Commands: [java.edit.organizeImports, java.project.refreshDiagnostics, java.project.import, java.navigate.openTypeHierarchy, java.project.removeFromSourcePath, java.project.listSourcePaths, java.project.resolveStackTraceLocation, java.project.getAll, java.project.isTestFile, java.project.getClasspaths, java.navigate.resolveTypeHierarchy, java.edit.stringFormatting, java.project.getSettings, java.project.updateSourceAttachment, java.project.upgradeGradle, java.project.resolveSourceAttachment, java.project.addToSourcePath]
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.828
!MESSAGE >> document/hover
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.831
!MESSAGE Starting org.eclipse.m2e.core
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.831
!MESSAGE >> document/documentHighlight
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.831
!MESSAGE Started org.eclipse.m2e.core 1ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.833
!MESSAGE >> document/signatureHelp
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.865
!MESSAGE ProjectRegistryRefreshJob finished 34ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.865
!MESSAGE Starting org.eclipse.buildship.core
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.873
!MESSAGE Started org.eclipse.buildship.core 8ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.896
!MESSAGE LoadingGradleVersionJob finished 23ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:36.938
!MESSAGE >> initialized
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:37.141
!MESSAGE Workspace initialized in 244ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:37.146
!MESSAGE >> workspace/didChangeWatchedFiles
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:37.153
!MESSAGE >> initialization job finished
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:37.154
!MESSAGE >> workspace/didChangeConfiguration
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:37.155
!MESSAGE >> workspace/didChangeWatchedFiles
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:37.160
!MESSAGE >> New configuration: {}
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:37.164
!MESSAGE >> workspace/didChangeWatchedFiles
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:37.172
!MESSAGE >> workspace/didChangeWatchedFiles
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:37.277
!MESSAGE >> build jobs finished
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:37.278
!MESSAGE >> registerWatchers'
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:37.279
!MESSAGE >> registerFeature 'workspace/didChangeWatchedFiles'
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:37.280
!MESSAGE >> watchers registered
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:39.086
!MESSAGE >> document/hover
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:39.087
!MESSAGE >> document/documentHighlight
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 11:27:39.087
!MESSAGE >> document/signatureHelp
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 22:03:16.505
!MESSAGE >> document/hover
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 22:03:16.506
!MESSAGE >> document/documentHighlight
!ENTRY org.eclipse.jdt.ls.core 1 0 2026-01-15 22:03:16.507
!MESSAGE >> document/signatureHelp

View File

@@ -1,3 +1,4 @@
INDEX VERSION 1.131+D:\Git\workspace\~\.emacs.d\cache\jdtls-workspace\.metadata\.plugins\org.eclipse.jdt.core INDEX VERSION 1.131+D:\Git\workspace\~\.emacs.d\cache\jdtls-workspace\.metadata\.plugins\org.eclipse.jdt.core
1865797976.index 1865797976.index
3906678465.index 3906678465.index
2238567309.index

View File

@@ -1,2 +1,4 @@
2026-01-09 15:45:04,949 [Worker-1: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is not available. Remote download required. 2026-01-09 15:45:04,949 [Worker-1: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is not available. Remote download required.
2026-01-09 15:45:06,812 [Worker-1: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. 2026-01-09 15:45:06,812 [Worker-1: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read.
2026-01-15 11:27:34,362 [Worker-3: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update.
2026-01-15 11:27:36,869 [Worker-0: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read.

View File

@@ -15,6 +15,16 @@
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
</natures> </natures>
<linkedResources> <linkedResources>
<link>
<name>src/Main.java</name>
<type>1</type>
<location>d:/Git/workspace/java/HashMap/Main.java</location>
</link>
<link>
<name>src/Matrix.java</name>
<type>1</type>
<location>d:/Git/workspace/java/Matrix/Matrix.java</location>
</link>
<link> <link>
<name>src/guessnum.java</name> <name>src/guessnum.java</name>
<type>1</type> <type>1</type>

Binary file not shown.