codeforces 598A Tricky Sum
题目链接:http://codeforces.com/contest/598/problem/A
题目分类:大数
题意:1到n 如果是2的次方则减去这个数,否则就加上这个数,求最后的结果是多少
题目分析:数很大,关键是精度问题,刚开始用__int64和double发现都是不对的,后来发现用long long 可以过
代码:
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL a[]={,,,,,,,,,
,,,,,,
,,,,,,
,,,,,
,,,,};
int main()
{
int t;
LL n;
LL ans;
cin>>t;
while(t--)
{
cin>>n;
ans=n*(+n)/;
//cout<<ans<<endl;
for(int i=;i<=;i++)
{
if(n>=a[i])
{
ans-=*a[i];
}
else
{
break;
}
}
cout<<ans<<endl;
}
return ;
}
codeforces 598A Tricky Sum的更多相关文章
- CodeForces - 598A Tricky Sum (数学,快速幂的运用)
传送门: http://codeforces.com/problemset/problem/598/A A. Tricky Sum time limit per test 1 second memor ...
- Educational Codeforces Round 1 A. Tricky Sum 暴力
A. Tricky Sum Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/problem ...
- Codeforces 396B On Sum of Fractions 数论
题目链接:Codeforces 396B On Sum of Fractions 题解来自:http://blog.csdn.net/keshuai19940722/article/details/2 ...
- codeforces 963A Alternating Sum
codeforces 963A Alternating Sum 题解 计算前 \(k\) 项的和,每 \(k\) 项的和是一个长度为 \((n+1)/k\) ,公比为 \((a^{-1}b)^k\) ...
- codeforces 1217E E. Sum Queries? (线段树
codeforces 1217E E. Sum Queries? (线段树 传送门:https://codeforces.com/contest/1217/problem/E 题意: n个数,m次询问 ...
- Codeforces 577B Modulo Sum
http://codeforces.com/problemset/problem/577/B 题意:有n个数,求有无一个子序列满足和是m的倍数 思路:用模下的背包做,发现n是十的六次方级别,但是有个神 ...
- Codeforces 85 D. Sum of Medians
题目链接:http://codeforces.com/contest/85/problem/D 做法果然男默女泪啊..... 大概就是直接开了一个$vector$每次插入删除都用自带的$insert$ ...
- Codeforces 797B - Odd sum
B. Odd sum 题目链接:http://codeforces.com/problemset/problem/797/B time limit per test 1 second memory l ...
- Codeforces 963A Alternating Sum(等比数列求和+逆元+快速幂)
题目链接:http://codeforces.com/problemset/problem/963/A 题目大意:就是给了你n,a,b和一段长度为k的只有'+'和‘-’字符串,保证n+1被k整除,让你 ...
随机推荐
- Step by step guide to set up master and slave machines(转)
Note: There is no need to install Jenkins on the slave machine. On your master machine go to Manage ...
- C++ vs.net设置UTF8字符
1.将main.cpp改成utf-8编码,方法是点击main.cpp,然后选择菜单文件->高级保存选项.[所有源码都要转换成uft-8] 2.在你的main函数里,设置如下代码,完美解决qt5的 ...
- 找出并解决 JavaScript 和 Dojo 引起的浏览器内存泄露问题
简介: 如果大量使用 JavaScript 和 Ajax 技术开发 Web 2.0 应用程序,您很有可能会遇到浏览器的内存泄漏问题.如果您有一个单页应用程序或者一个页面要处理很多 UI 操作,问题可能 ...
- IT忍者神龟之Oracle DBA经常使用查询吐血列举
–1. 查询系统全部对象 select owner, object_name, object_type, created, last_ddl_time, timestamp, status from ...
- 浅析SSH核心原理(二)
Hibernate是一个开放源代码的ORM(对象-关系映射)框架,它对JDBC进行了非常轻量级的对象封装,使得Java程序员可以随心所欲的使用对象编程思维来操纵数据库. Hibernate可以应用在任 ...
- asp.net导出Excel类库
using System; using System.Collections.Generic; using System.Reflection; using System.Web; using Exc ...
- EasyUI - SplitButton 分割按钮
效果: html代码: <!--使用标签创建,直接使用即可,不必使用js代码--> <%--<a href="javascript:void(0)" id= ...
- form里两个submit按钮,在onsubmit中判断哪个被点
记下别人的解决方法(有效): 方法1:(已验证过) <form name="form1" onsubmit="show()"> ..... < ...
- Oracle Data Guard 创建物理Standby数据库
创建物理备库 机器名 a1 a2 IP: 192 ...
- linux内核系统调用--sendfile函数
在apache,nginx,lighttpd等webserver其中,都有一项sendfile相关的配置,在一些网上的资料都有谈到sendfile会提升文件传输性能,那sendfile究竟是什么呢?它 ...