Let,s chat!****

30 条评论

  • @ 2025-7-20 12:50:01

    //小明爱集合 #include #include <unordered_set> #include #include

    using namespace std;

    int main() { ios::sync_with_stdio(false); cin.tie(nullptr);

    int T;
    cin >> T;
    while (T--) {
        int n, m;
        cin >> n >> m;
        unordered_set<int> setA;
        for (int i = 0; i < n; ++i) {
            int num;
            cin >> num;
            setA.insert(num);
        }
    
        int common = 0;
        for (int i = 0; i < m; ++i) {
            int num;
            cin >> num;
            if (setA.count(num)) {
                common++;
            }
        }
    
        int totalUnique = setA.size() + m - common;
        int similarity = (totalUnique == 0) ? 0 : static_cast<int>((common * 100.0) / totalUnique);
        cout << similarity << "\n";
    }
    
    return 0;
    

    } //约瑟夫问题 #include #include

    using namespace std;

    int main() { int n, m; cin >> n >> m;

    vector<int> people(n);
    for (int i = 0; i < n; ++i) {
        people[i] = i + 1; // 编号从1到n
    }
    
    vector<int> result;
    int pos = 0; // 当前报数的起始位置
    
    while (!people.empty()) {
        pos = (pos + m - 1) % people.size(); // 计算出列位置
        result.push_back(people[pos]);
        people.erase(people.begin() + pos); // 移除出列的人
    }
    
    for (int num : result) {
        cout << num << " ";
    }
    cout << endl;
    
    return 0;
    

    } //八个方向 #include #include #include

    using namespace std;

    // 八个方向:上、下、左、右、左上、右上、左下、右下 const int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1}; const int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};

    bool canFindTreasure(int N, const vector<vector>& maze) { vector<vector> visited(N, vector(N, false)); queue<pair<int, int>> q;

    // 起点是 (0, 0)(因为题目描述是 (1,1),但代码中通常从 0 开始)
    if (maze[0][0] == 1) return false; // 题目保证起点没有蝙蝠,但可以加上检查
    if (maze[0][0] == 2) return true;  // 起点就是宝藏
    
    q.push({0, 0});
    visited[0][0] = true;
    
    while (!q.empty()) {
        auto [x, y] = q.front();
        q.pop();
        
        for (int i = 0; i < 8; ++i) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            
            if (nx >= 0 && nx < N && ny >= 0 && ny < N && !visited[nx][ny]) {
                if (maze[nx][ny] == 2) return true;
                if (maze[nx][ny] == 0) {
                    visited[nx][ny] = true;
                    q.push({nx, ny});
                }
            }
        }
    }
    
    return false;
    

    }

    int main() { int N; cin >> N;

    vector<vector<int>> maze(N, vector<int>(N));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> maze[i][j];
        }
    }
    
    if (canFindTreasure(N, maze)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
    

    } //马走日 #include #include

    using namespace std;

    // 马的8种移动方向(“日”字形) const int dx[] = {1, 2, 2, 1, -1, -2, -2, -1}; const int dy[] = {2, 1, -1, -2, -2, -1, 1, 2};

    int count = 0;

    void dfs(int x, int y, int n, int m, vector<vector>& visited, int steps) { if (steps == n * m) { count++; return; }

    for (int i = 0; i < 8; ++i) {
        int nx = x + dx[i];
        int ny = y + dy[i];
    
        if (nx >= 0 && nx < n && ny >= 0 && ny < m && !visited[nx][ny]) {
            visited[nx][ny] = true;
            dfs(nx, ny, n, m, visited, steps + 1);
            visited[nx][ny] = false; // 回溯
        }
    }
    

    }

    int main() { int T; cin >> T;

    while (T--) {
        int n, m, x, y;
        cin >> n >> m >> x >> y;
    
        vector<vector<bool>> visited(n, vector<bool>(m, false));
        visited[x][y] = true; // 标记起点
        count = 0;
    
        dfs(x, y, n, m, visited, 1); // 初始步数为1(起点已访问)
    
        cout << count << endl;
    }
    
    return 0;
    

    } //全排列问题 #include #include

    using namespace std;

    void generatePermutations(int n, vector& current, vector& used) { if (current.size() == n) { for (int num : current) { cout << num << " "; } cout << endl; return; }

    for (int i = 1; i <= n; ++i) {
        if (!used[i]) {
            used[i] = true;
            current.push_back(i);
            generatePermutations(n, current, used);
            current.pop_back();
            used[i] = false;
        }
    }
    

    }

    int main() { int n; cin >> n;

    vector<int> current;
    vector<bool> used(n + 1, false); // 数字从1到n
    
    generatePermutations(n, current, used);
    
    return 0;
    

    }

    • @ 2025-7-20 9:37:12

      #include <bits/stdc++.h> using namespace std;

      int main() { ios::sync_with_stdio(false); cin.tie(0);

      int N;
      long long C;
      cin >> N >> C;
      vector<long long> a(N);
      unordered_map<long long, long long> countMap;
      
      for (int i = 0; i < N; i++) {
          cin >> a[i];
          countMap[a[i]]++;
      }
      
      long long ans = 0;
      
      if (C == 0) {
          for (int i = 0; i < N; i++) {
              ans += (countMap[a[i]] - 1);
          }
      } else {
          for (int i = 0; i < N; i++) {
              long long y = a[i] - C;
              if (y < 0) {
                  continue;
              }
              if (countMap.find(y) != countMap.end()) {
                  ans += countMap[y];
              }
          }
      }
      
      cout << ans << endl;
      
      return 0;
      

      }

      • @ 2025-7-20 9:25:23

        #include<bits/stdc++.h> using namespace std;

        int main() { ios::sync_with_stdio(false); cin.tie(0);

        int t;
        cin >> t;
        while (t--) {
            int m, n;
            cin >> m >> n; // m: 集合B的大小, n: 集合A的大小
            
            vector<int> B(m);
            vector<int> A(n);
            
            // 读取集合B的元素
            for (int i = 0; i < m; i++) {
                cin >> B[i];
            }
            // 读取集合A的元素
            for (int i = 0; i < n; i++) {
                cin >> A[i];
            }
            
            // 创建计数数组(元素范围1~50000)
            vector<int> count(50001, 0);
            
            // 统计集合B中每个元素的出现次数
            for (int num : B) {
                if (num >= 1 && num <= 50000) {
                    count[num]++;
                }
            }
            
            bool isSubset = true;
            // 检查集合A的元素是否都存在于集合B中且数量不超过
            for (int num : A) {
                if (num < 1 || num > 50000) {
                    isSubset = false;
                    break;
                }
                if (count[num] > 0) {
                    count[num]--;
                } else {
                    isSubset = false;
                    break;
                }
            }
            
            if (isSubset) {
                cout << "Yes\n";
            } else {
                cout << "No\n";
            }
        }
        return 0;
        

        }

        • 同志,人呢??? 答案呢???

          • @ 2025-7-18 14:55:46

            #include using namespace std; struct node{ char data; int left,right; }; node Betree[10]; void pre(int root){ if(root>=0){ cout<<Betree[root].data; pre(Betree[root].left); pre(Betree[root].right); } } void in(int root){ if(root>=0){ in(Betree[root].left); cout<<Betree[root].data; in(Betree[root].right); } } void back(int root){ if(root>=0){ back(Betree[root].left); back(Betree[root].right); cout<<Betree[root].data; } } int main(){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>Betree[i].data>>Betree[i].left>>Betree[i].right; } pre(0); cout<<endl; in(0); cout<<endl; back(0)l; cout<<endl; return 0; }

            • 同志们 人呢!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

              • 一平兄,敢紧发啊!!!!!!!!!!!!!!!!!!!!!!

                • 今天答案???

                  • @ 2025-7-16 17:26:51

                    本次答案

                    🤣 1
                    • @ 2025-7-16 17:26:42

                      重要的事情说三遍!!!

                      • @ 2025-7-16 17:26:22

                        '1': B '2': C '3': A '4': A '5': D '6': C '7': D '8': C '9': B '10': B

                        • @ 2025-7-16 17:26:19

                          '1': B '2': C '3': A '4': A '5': D '6': C '7': D '8': C '9': B '10': B

                          • @ 2025-7-16 17:26:15

                            '1': B '2': C '3': A '4': A '5': D '6': C '7': D '8': C '9': B '10': B

                            • @ 2025-7-16 14:02:16

                              #include iostream #include queue using namespace std; int main() { queue<int1️⃣ q; int num; for (int i = 0; i < 5; i++) { cin >> num; q.push(num); } for (int i = 0; i < 3; i++) { int front = q.front(); q.pop(); if (i > 0) { cout << " "; } cout << front; } cout << endl; cout << q.front() << endl; return 0; } 1️⃣:>

                              • @ 2025-7-15 17:10:17

                                @所有人

                                • @ 2025-7-15 17:07:42

                                  本次答案: '1': B '2': A '3': A '4': C '5': A

                                  • #include<bits/stdc++.h>
                                    using namespace std;
                                    struct node{
                                    	int data;
                                    	node *next;
                                    	node *prev;
                                    };
                                    int main()
                                    {
                                    	node a={1,NULL,NULL};
                                    	node b={2,NULL,NULL};
                                    	node c={3,NULL,NULL};
                                    	a.next=&b;
                                    	b.next=&c;
                                    	c.prev=&b;
                                    	b.prev=&a;
                                    	
                                    	node d={4,NULL,NULL};//头部 
                                    	node e={5,NULL,NULL};//b,c之间 
                                    	node f={6,NULL,NULL};//尾部 
                                    	
                                    	node *pd=&d;
                                    	node *pa=&a; 
                                    	node *pb=&b;
                                    	node *pe=&e;
                                    	node *pc=&c;
                                    	node *pf=&f;
                                    	
                                    	pa->prev=pd;
                                    	pd->next=pa;
                                    	
                                    	pe->next=pc;
                                    	pe->prev=pb;
                                    	pb->next=pe;
                                    	pc->prev=pe;
                                    	
                                    	pc->next=pf;
                                    	pf->prev=pc;
                                    	
                                    	node *p1=&d;
                                    	while(p1!=NULL){
                                    		cout<<p1->data<<" ";
                                    		p1=p1->next;
                                    	}
                                    	cout<<endl;
                                    	
                                    	node *p2=&f;
                                    	while(p2!=NULL){
                                    		cout<<p2->data<<" ";
                                    		p2=p2->prev;
                                    	}
                                    	
                                    
                                    return 0;
                                    }
                                    
                                    • @ 2025-7-15 13:38:45

                                      #include using namespace std; //定义结构体 struct node{ int data; node *next; node *pre; }; int main(){ //1、定义3个结点并连接起来 node a={1, NULL, NULL}; node b={2, NULL, NULL}; node c={3, NULL, NULL}; a.next=&b; b.pre=&a; b.next=&c; c.pre=&b; node *p=&c; while(p!=NULL){ cout<data<<" "; p=p->pre; }

                                      return 0;
                                      

                                      }

                                      • @ 2025-7-15 10:28:12

                                        #include using namespace std; struct node{ char data; node *next; }; int main() { node a={'A',NULL}; node b={'B',NULL}; node c={'C',NULL}; node d={'D',NULL}; node e={'E',NULL}; a.next=&b; b.next=&c; c.next=&d; d.next=&e; node *p; p=&a; while(p!=NULL){ cout<<①>adta<<endl; p=p->next; } return 0; } ①:p-

                                        • 丁丁丁丁顿吗丁丁丁丁顿(肌肉橘子)

                                          • 丁丁丁丁顿吗丁丁丁丁顿(肌肉橘子)

                                            • @ 2025-7-14 17:11:39

                                              答案: '1': C '2': C '3': D '4': C '5': A '6': A '7': D '8': B '9': D '10': A

                                              • @ 2025-7-14 16:03:48

                                                没有

                                                • @ 2025-7-14 15:54:02

                                                  有人吗

                                                  • @ 2025-7-14 15:02:11

                                                    #include using namespace std; int main() { int n; cin>>n; int a[2000]; a[1]=1; a[2]=2; for(int i=3;i<=n;i++){ a[i]=a[i-2]+a[i-1]; } cout<<a[n]<<endl; return 0; }

                                                    • @ 2025-7-14 14:49:01

                                                      这才是对的 #include using namespace std; int main() { int n; cin>>n; int a[2000]; a[1]=1; a[2]=2; for(int i=3;i<=n;i++){ a[i]=a[i-2]+a[i-1];

                                                      }
                                                      cout<<a[n]-1<<endl;
                                                      return 0;
                                                      

                                                      }

                                                      • @ 2025-7-14 14:48:44

                                                        错了......

                                                        • @ 2025-7-14 14:47:49

                                                          #include using namespace std; int main() { int n; cin>>n; int a[2000]; a[1]=1; a[2]=2; for(int i=3;i<=n;i++){ a[i]=a[i-2]+a[i-1];

                                                          }
                                                          cout<<a[n]<<endl;
                                                          return 0;
                                                          

                                                          }

                                                          • @ 2025-7-14 14:34:01

                                                            • @ 2025-7-14 13:42:46

                                                              你们怎么都不投票啊🤔🤔🤔

                                                              • 1