#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);
}
}相关推荐
VSCode玩转Arduino:手把手解决‘未定义Serial’和头文件找不到的坑
本文详细介绍了在VSCode中配置Arduino开发环境时遇到的‘未定义Serial’和头文件找不到问题的解决方案。通过修改c_cpp_properties.json文件、调整IntelliSense引擎设置以及添加正确的库路径,开发者可以高效解决这些常见错误,提升开发体验。文章还提供了针对不同开发板和平台的高级配置技巧,确保配置的长期有效性。
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--) {
AD620仪表放大器模组实战:从调零到信号放大的完整指南
本文详细介绍了AD620仪表放大器模组的实战应用,从调零到信号放大的完整指南。AD620模组以其专业级性能和易用性成为微弱信号放大的首选,集成了AD620芯片、LM358运放和7660电源转换芯片。文章提供了调零技巧、增益设置方法以及单端与差分输入的正确连接方案,并通过心电信号采集和称重传感器等实际案例展示了其广泛应用。
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
MavLink协议入门
MAVLink是一个非常轻量化的开源的消息协议,用于无人机之间的通信以及无人机机载设备之间的通信。
无人自行车平衡控制:最小二乘法动态零点拟合实践
本文探讨了无人自行车平衡控制中动态零点的重要性及实现方法。通过最小二乘法拟合车头角度与ROL值的线性关系,解决了固定零点在转向时导致的稳定性问题。实践表明,动态零点拟合能显著提升系统平衡稳定性并降低能耗。
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
10天冲刺国自然基金!用这套实战AI提示词指令教程,助你中标率翻倍!亲测DeepSeek和ChatGPT不好用
虽然以上国自然提示词指令经过反复实测,但并不是万能无脑帮你搞定所有,大模型AI的特性是你专业领域能力越强,它的智商表现就会更加强大,通过以上提示词教程的使用,大大提升中标概率是肯定的。还有就是大模型的使用上,不是市面上大家都说好的就一定适用,目前来看,Gemini和Claude的两个模型是非常适合国自然本子的修改的。在使用大模型进行国自然本子撰写修改时,首先是角色的设定,然后是目标和背景的描述,好用的提示词指令都是要经过无数次的实测,比对输出结果后又反复调整,达到最佳的效果状态的提示词指令。
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的幂次共有多少个,用等比数列求和公式求出它们的和,减去两倍的它即可。 但是我发现...
【QNX+Android虚拟化方案】01 - 芯片介绍
【QNX+Android虚拟化方案】01 - 芯片介绍
YOLOv11的多任务学习:检测+分割+姿态估计-(扩展模型头部分支,实现多任务联合训练)
YOLOv11作为Ultralytics团队于2024年9月发布的最新YOLO系列模型,在前代版本基础上进行了多项架构创新,使其成为支持多任务学习的理想框架。其核心改进包括引入C2PSA(跨阶段局部自注意)模块,将跨阶段局部网络和自注意机制优势结合,使模型能够更有效地跨多层捕获上下文信息。C3k2模块取代了之前的C2f模块,作为CSP Bottleneck的自定义实现,使用两个较小卷积核而非一个大卷积核,在保持准确性的同时提高了效率。 多任务学习(Multi-Task Learning, MTL)在YOL
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中不
基于Simulink的电力电子系统电磁兼容性(EMC)仿真
在电力电子系统中,由于高频开关器件的存在,会产生大量的电磁干扰(EMI),这对系统的稳定性和可靠性提出了挑战。Simulink 提供了一个强大的仿真环境,可以用来设计、分析和验证电力电子系统的电磁兼容性。本教程将详细介绍如何使用 Simulink 进行电力电子系统的电磁兼容性仿真。通过本教程,我们详细介绍了如何使用 Simulink 进行电力电子系统的电磁兼容性仿真。为了模拟电力电子系统中的电磁干扰(EMI),我们需要添加噪声源模块。为了更好地分析系统的电磁兼容性特性,可以在模型中添加频谱分析工具。
【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
Data-Structures-and-Algorithm-Analysis-in-Java.pdf
作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...
jdk-8u144-linux-x64.tar.gz.
该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包
CF#320 Div.2 总结
比赛网址:cf#320 Div.2 晚上11点开始的比赛,持续2个半小时。结束时有两道题题过了预测数据,分时是A题和C题。 比赛开始的时候,理所当然地从A题开始看起。A题比较容易,稍微分析一下就可以看出是一道10进制转2进制的题目,虽然题目比较简单,但是由于敲代码不够熟练,并且还要测试一些数据的原因,当我提交时已经有接近2000人A了此题。 然后我开始看B题,B题题意比较容易理解,而且我觉得
大中型超市收银系统(可直接运行)
光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开
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
STM32F407中文手册
STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。
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
358



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



