CodeForces 598A Tricky Sum
水题。
#include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<algorithm> using namespace std;long long b[32];void f() {b[0]=1;for(int i=1;i<=30;i++) b[i]=2*b[i-1]; }int main() {f();int T; scanf("%d",&T);while(T--){long long n; scanf("%lld",&n);long long ans=(1+n)*n/2;for(int i=0;i<=30;i++)if(b[i]<=n) ans=ans-b[i]-b[i];printf("%lld\n",ans);}return 0; }
转载于:https://www.cnblogs.com/zufezzt/p/5469130.html
CodeForces 598A Tricky Sum相关推荐
- 「一题多解」【CodeForces 85D】Sum of Medians(线段树 / 分块)
题目链接 [CodeForces 85D]Sum of Medians 题目大意 实现一个setsetset,支持插入,删除,求∑a5k+3∑a5k+3\sum a_{5k+3}.注意,setsets ...
- Codeforces 1196B Odd Sum Segments
https://codeforces.com/contest/1196/problem/B 题解:贪心 /* *@Author: STZG *@Language: C++ */ #include &l ...
- Educational Codeforces Round 37-F.SUM and REPLACE (线段树,线性筛,收敛函数)
F. SUM and REPLACE time limit per test2 seconds memory limit per test256 megabytes inputstandard inp ...
- Codeforces 797B - Odd sum
B. Odd sum 题目链接:http://codeforces.com/problemset/problem/797/B time limit per test 1 second memory l ...
- codeforces 577B Modulo Sum
题目链接:[codeforces 577B] 问能不能在大小是n的数列中取出几个数,使得他们的和是m的倍数 如果n>m,那么无论n个数是多少,都可以,这是一个定理 所以我们要讨论的就是n< ...
- Tricky Sum
In this problem you are to calculate the sum of all integers from 1 to n, but you should take all po ...
- Codeforces 963A Alternating Sum 【数论+数学】
官方题解这个样子我觉得说得比较清楚.Z我们可以朴素的预处理出来(注意乘法膜),q的话考点在于[分数取膜]即 (a/b)%P = a* inverse of b %P 这就涉及到算b的逆元,我用的是欧几 ...
- CodeForces - 1373D Maximum Sum on Even Positions(最大连续子段和)
题目链接:点击查看 题目大意:给出一个长度为 n 的数列 a ,允许选择一个子串进行翻转,问最后可以得到的,偶数位置的数字之和的最大值是多少 题目分析:模拟几次不难发现,我们翻转的长度必须是偶数才能有 ...
- codeforces 1060b Maximum Sum of Digits(思维题)
You are given a positive integer n Let S(x) be sum of digits in base 10 representation of x, for exa ...
最新文章
- Asp.net MVC4.0(net4.5) 部署到window server 2003上的解决方案
- 信息学奥赛一本通(1236:区间合并)
- 梯度下降法参数更新公式的推导
- android 学习随笔二十三(动画:Fragment )
- C++11 random库
- 放大你的Rstudio窗口字体
- jQuery将json对象转为字符串,将json字符串转为对象
- Java List集合排序 Java8 List集合排序方法 Java Lambda集合排序
- 《动手学深度学习》入门环境安装
- 中国科学院计算机所刘夏真,中国科学院大学2015年博士生录取名单公示(55)
- Protocol(基本语法和使用场景)
- 服务器 exe文件,服务器无故生成exe文件,套路有点深
- 2345浏览器如何启用过滤弹窗广告
- python青少年编程_机器人Python青少年编程开发实例
- vs2005 sp1补丁安装,报1718错误: 数字签名拒绝
- tensorflow 1.14 ssd_mobilenet_v1 模型训练
- DrawerLayout must be measured with MeasureSpec.EXACTLY.
- adb 命令(系统基础类-获取手机系统属性)
- G5冲锋G6接应,浪潮存储步步为营
- PHP中lev是什么意思,_lev - SegmentFault 思否