#include <bits\stdc++.h>
using namespace std;
#define LL long long
const LL MAXN=1000000000;
LL a[30]={1};
LL b[30]={1};
int main()
{
for(int i=1;i<=30;i++)
a[i]=2*a[i-1];
for(int i=1;i<30;i++)
b[i]=a[i]+b[i-1];
int t;
LL n,ans;
scanf("%d",&t);
while(t--)
{
scanf("%I64d",&n);
ans=n*(n+1)/2;
int i=0;
while(n>=a[i])
i++;
i--;
ans-=2*b[i];
printf("%I64d\n",ans);
}
}相关推荐
±10V ADC 输入电路的高共模差分输入电压
这篇文章分析了±10V ADC输入电路的设计需求与挑战,重点讨论了高共模差分输入电压的处理方案。文章首先明确了设计目标,即安全转换±10V差分信号并保持信号完整性,同时克服高共模电压、阻抗匹配和噪声优化等难点。随后详细比较了仪表放大器和差分放大器的性能特点,并提出了器件选型理论。在信号链架构部分,文章通过公式推导阐述了增益设置、共模抑制设计和输入阻抗匹配等关键技术。此外,还建立了噪声源模型,提出了噪声优化措施。最后,文章总结了设计验证方法,并扩展了在工业保护和生物电信号采集等场景的应用。该设计强调根据具体应
Coderforce 598A Tricky Sum (数学)
题意:求数字之和,但是要减去2的倍数 思路:直接求... #include #include #include #include #include #include using namespace std; int main () { long long sum,n,t,x; int i; scanf("%lld",&t); while(t--) {
解决Anaconda环境下catkin_make编译报错:Python路径冲突与empy模块缺失
本文详细分析了在Anaconda环境下使用catkin_make编译时出现的Python路径冲突与empy模块缺失问题,提供了快速解决方案和永久性环境配置方法。通过显式指定Python解释器路径或调整Anaconda配置,有效解决编译报错问题,适用于ROS开发与科学计算并行的场景。
cf 598 A
A. Tricky Sum time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In this problem you are to calculate the sum o
手把手教你用Verilog在FPGA上驱动0.96寸OLED(I2C协议,含完整代码和字库)
本文详细介绍了如何使用Verilog在FPGA上通过I2C协议驱动0.96寸OLED显示屏,包含完整的硬件连接指南、I2C协议解析、Verilog代码实现及字库设计。从初始化序列到字符显示引擎,提供可立即上手的解决方案,适合嵌入式系统开发者快速实现OLED显示功能。
FastDDS之共享内存
transport层负责为DDS用户数据收发和服务发现提供通信。包含UDP,TCP,SHM。
CF 598A Tricky Sum【规律】
A. Tricky Sum time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In this problem you are to calculate the sum o
在windows上,在WSL 2(windows subsystem linux) 里一步步安装vLLM
本文介绍了在Windows系统上通过WSL2配置GPU加速的AI开发环境的完整流程。主要包括四个步骤: 1)安装WSL2并配置Ubuntu环境; 2)安装NVIDIA驱动和CUDA工具包; 3)搭建Python虚拟环境并安装vLLM; 4)验证环境并启动AI模型服务。
CF598A Tricky Sum
题意: 该题目有多组数据,每组数据给出一个n,让你求出从1到n的和,但是其中每当遇到一个数是2的次幂时,就要变加为减。例如输入n=4,那么计算算式为-1-2+3-4=-4,因为1是2^0,2是2^1,4是2^2。共有t组数据。 其实做法很简单,把从1到n的和用等差数列算出来,然后用log2n计算出不大于n的2的幂次共有多少个,用等比数列求和公式求出它们的和,减去两倍的它即可。 但是我发现...
第二篇:APS智能排产实战:OR-Tools与coptpy从入门到案例
专注于具体的技术实现,包括 OR-Tools 和 coptpy 的详细使用指南、建模技巧、日志解读,以及一个完整的两阶段生产排程案例。适合准备动手开发 APS 系统的工程师和研究者。
小波变换(深入浅出)
小波变换
CF598
CF EDU 1 A Tricky Sum 题目链接 思路 首先如果2的次幂是减号的话, 我们可以将2的次幂这个等比数列求出来。 根据等比数列求和公式a1(1−qn)1−q\frac{a1(1 - q^n)}{1-q}1−qa1(1−qn), 将公比2代入, 将a1为1 代入, 可得∑i=0n2i=2n+1−1\sum_{i=0}^{n}2^i = 2^{n+1} - 1∑i=0n2i=2n+1−1。那么, 原题我们就可以将答案减去这个2的次幂和了 再来考虑剩下的: 原题中剩下的都是正的, 为1到n中不
【2025软考高级架构师】基础知识部分——6、软件架构设计
(1)架构是对系统的抽象(2)架构由多个结构组成(3)任何软件都存在架构(4)元素及其行为的集合构成架构的内容(5)架构具有“基础”性(6)架构隐含有“决策”
【codeforces】-598A-Tricky Sum(数列求和,2的幂为负)
A. Tricky Sum time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In this problem you are to calculate the sum o
win10 跳过U8环境检测的IE WebControls.rar
win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。
C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片
基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正
CF#320 Div.2 总结
比赛网址:cf#320 Div.2 晚上11点开始的比赛,持续2个半小时。结束时有两道题题过了预测数据,分时是A题和C题。 比赛开始的时候,理所当然地从A题开始看起。A题比较容易,稍微分析一下就可以看出是一道10进制转2进制的题目,虽然题目比较简单,但是由于敲代码不够熟练,并且还要测试一些数据的原因,当我提交时已经有接近2000人A了此题。 然后我开始看B题,B题题意比较容易理解,而且我觉得
TMS_WebGMaps_1.9.8.0_Full_Source
TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder
cf 20a BerOS file system
#include #include using namespace std; int main() { string s; cin>>s; bool flag=false; int p=s.length()-1; while(s[p]=='/') p--; if(p==-1) s="/"; else
SIMATIC S7-1200, S7-1500 PID 控制[手册]
SIMATIC S7-1200, S7-1500 PID 控制[手册]
cf 88b Keyboard
#include #include #include using namespace std; #define del(a,b) memset(a,b,sizeof(a)) struct node { int x,y; }nn[900]; int aa[130]; bool flag; int n,m,x,q,ans,snum; char kb[33][33]; string s;
cf #327 Div.2 Problem B Rebranding
#include #include #include using namespace std; int n,m; char aa[30]={'a'}; char s[200005]; char *ss[200005]; char a,b; int main() { for(int i=1;i<26;i++) aa[i]=aa[i-1]+1; scanf("%d
cf#320 Div.2 Problem C A Problem about Polyline
#include #include #include using namespace std; double ans,a; int x,y; int main(){ scanf("%d%d",&x,&y); if(y==x){ printf("%.12lf\n",(double)x); } else if(x<y){ print
cf 2a Winner
#include #include #include using namespace std; string ss[1005]; int x[1005]; int main() { int N; string win; int maxn=0; cin>>N; map M; for(int i=0;i<N;i++) { c
cf 8a Train and Peter
#include #include #include using namespace std; int main() { string s,s1,s2; bool f1=false,f2=false; cin>>s>>s1>>s2; int a,b; a=s.find(s1); if(a!=std::string::npos) {
cf#320 Div.2 Problem D "Or" Game
#include #include #include using namespace std; #define LL long long int n,k,x; int a[200005],l[200005],r[200005]; int main(){ scanf("%d%d%d",&n,&k,&x); for(int i=1;i<=n;i++) scanf(
cf#320 Div.2 Problem E Weakness and Poorness
这题的代码是参考比赛中大神的AC代码的,据说用到了三分思想和前缀和,这里先记下来,日后再消化 #include #include #include #include using namespace std; int N; int A[200005]; double f(double x){ double res=0,s1=0,s2=0; for(int i=0;i
cf 15a Cottage Village
#include #include #include using namespace std; struct node { double x,a,l,r; }nn[1005]; int n; double t; bool cmp(const node &n1,const node &n2) { return n1.x<n2.x; } int main() { scan
cf 75c Modified GCD
#include #include using namespace std; int gcd(int a,int b) { int t; if(a<b) { t=a;a=b;b=t; } while(t=a%b) { a=b; b=t; } return b; } int main(
cf 9a Die Roll
#include #include using namespace std; int main() { int a,b; scanf("%d%d",&a,&b); a=max(a,b); if(a==1) printf("1/1\n"); else if(a==2) printf("5/6\n"); else if
1959



被折叠的 条评论
为什么被折叠?



