当前位置: 首页 > news >正文

每日错题(2024年9月1日)

Problem - C - Codeforces

思路非常简单,但是对我感觉比较难想

sum总和

sum_异或和

sum + sum_ + x = 2 * x

解得,x = sum + sum_

#include <bits/stdc++.h>using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> PII;
#define pb emplace_back
//#define int ll
#define all(a) a.begin(),a.end()
#define x first
#define y second
#define ps push_back
#define endl '\n'
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define lc u << 1
#define rc u << 1 | 1void solve();const int N = 1e6 + 10;signed main() {IOS;ll t = 1;cin >> t;while (t--)solve();return 0;
}
//sum+ === ___(suoyoujin)
void solve() {ll n; cin >> n;vector<ll> a(n+1);ll sum = 0,sum_ = 0;for(int i = 1; i <= n; ++ i){cin >> a[i];sum_ = sum_ ^ a[i];sum += a[i];}if((sum_<<1) == sum){cout << 0 << endl;cout << endl;return;}cout << 2 << endl;cout  << sum_ << " " << sum_ + sum << endl;
}


http://www.mrgr.cn/news/17466.html

相关文章:

  • Docker(完整实验版)
  • 二分查找 | 二分模板 | 二分题目解析
  • 时间戳:时间的数字化表达
  • 顶顶通热词模型配置热词方法(mod_cti基于FreeSWITCH)
  • Mysql:create table ... select ...报错
  • 18041 分期还款(加强版)
  • 进程间的通信(IPC)基础了解,匿名管道使用,有名管道使用
  • 9-8 束搜索
  • 栈和队列的学习以及实现+双端队列的底层原理
  • wiki.js 部署
  • 华为云征文 | Flexus X与宝塔面板的完美结合,让云管理更轻松
  • 读书闲思---2024.09.01
  • nginx部署前端vue项目步骤
  • Java网络编程概述
  • python 笔记 geo-bleu
  • OpenSetting组件的用法
  • 【秋招笔试】9.01字节跳动秋招(已改编)-三语言题解
  • vercel免费在线部署TodoList网页应用
  • C++之搜索二叉树(上)
  • docker实战扩展四( Dockerfile 中,COPY . .详细讲解)