A simple problem(湘大邀请赛)
A simple problem |
||
| Accepted : 61 | Submit : 418 | |
| Time Limit : 15000 MS | Memory Limit : 655360 KB | |
Problem DescriptionThere is a simple problem. Given a number N. you are going to calculate N%1+N%2+N%3+...+N%N. InputFirst line contains an integer T, there are T(1≤T≤50) cases. For each case T. The length N(1≤N≤1012). OutputOutput case number first, then the answer. Sample Input1 Sample OutputCase 1: 4 |
ps:http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1203
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <list>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#define mp make_pair
#define X first
#define Y second
#define MEMSET(a, b) memset(a, b, sizeof(a))
using namespace std; typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vi::iterator vi_it;
typedef map<int, int> mii;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vector<int>, greater<int> > rpqi;
typedef priority_queue<pii> pqp;
typedef priority_queue<pii, vector<pii>, greater<pii> > rpqp; const int MAX_N = + ;
const ll LL = ;
int a[MAX_N]; struct bigNum
{
ll bit[]; bigNum() {
} bigNum(const ll &b = ) {
bit[] = b % LL;
bit[] = b / LL;
bit[] = ;
} void format() {
bit[] += bit[] / LL;
bit[] %= LL;
bit[] += bit[] / LL;
bit[] %= LL;
} bigNum operator * (const bigNum &bg) const {
bigNum tmp();
for (int i = ; i < ; ++i) {
for (int j = ; j <= i; ++j) tmp.bit[i] += bit[j] * bg.bit[i - j];
}
tmp.format();
return tmp;
} void operator = (const bigNum &bg) {
for (int i = ; i < ; ++i) bit[i] = bg.bit[i];
} void operator *= (const bigNum &bg) {
*this = *this * bg;
} bigNum operator + (const bigNum &bg) const {
bigNum tmp();
for (int i = ; i < ; ++i) tmp.bit[i] = bit[i] + bg.bit[i];
tmp.format();
return tmp;
} void operator += (const bigNum &bg) {
*this = *this + bg;
} void half() {
if (bit[] % ) bit[] += LL;
bit[] /= ;
if (bit[] % ) bit[] += LL;
bit[] /= ;
bit[] /= ;
} void print() {
bool flag = false;
if (bit[]) printf("%I64d", bit[]), flag = true;
if (flag) printf("%09I64d", bit[]);
else if (bit[]) printf("%I64d", bit[]), flag = true;
if (flag) printf("%09I64d", bit[]);
else printf("%I64d", bit[]);
}
}; int main(int argc, char *argv[])
{
// freopen("D:\\in.txt", "r", stdin);
int t;
cin >> t;
for (int cas = ; cas <= t; ++cas) {
ll n;
scanf("%I64d", &n);
bigNum bn(n), ans();
int k = (int)sqrt((double)n);
for (int i = ; i <= k; ++i) {
bigNum tmp1(n / i - n / (i + ));
bigNum tmp2(n + n - i * (n / i + n / (i + ) + ));
tmp1 *= tmp2;
tmp1.half();
ans += tmp1;
}
ll tmp();
int lmt = (int)(n / (k + ));
for (int i = ; i <= lmt; ++i) tmp += n % i;
bigNum tt(tmp);
ans += tt;
printf("Case %d: ", cas);
ans.print();
puts("");
}
return ;
}
A simple problem(湘大邀请赛)的更多相关文章
- ACM: A Simple Problem with Integers 解题报告-线段树
A Simple Problem with Integers Time Limit:5000MS Memory Limit:131072KB 64bit IO Format:%lld & %l ...
- 【HDU 3483】 A Very Simple Problem (二项式展开+矩阵加速)
A Very Simple Problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- POJ 3468 A Simple Problem with Integers(分块入门)
题目链接:http://poj.org/problem?id=3468 A Simple Problem with Integers Time Limit: 5000MS Memory Limit ...
- hdu3483 A Very Simple Problem 非线性递推方程2 矩阵快速幂
题目传送门 题目描述:给出n,x,mod.求s[n]. s[n]=s[n-1]+(x^n)*(n^x)%mod; 思路:这道题是hdu5950的进阶版.大家可以看这篇博客hdu5950题解. 由于n很 ...
- 牛客NC15879 A Simple Problem
传送门:A Simple Problem 题意 给定两个序列s1和s2,同样的数字可以用相同的别的数字代替(并且也可以是出现过的数字),问s2在s1中出现了几次. 题解 首先预处理一下这两个序列,因为 ...
- hihoCoder 1427 : What a Simple Research(大㵘研究)
hihoCoder #1427 : What a Simple Research(大㵘研究) 时间限制:1000ms 单点时限:1000ms 内存限制:256MB Description - 题目描述 ...
- POJ 3468 A Simple Problem with Integers(线段树 成段增减+区间求和)
A Simple Problem with Integers [题目链接]A Simple Problem with Integers [题目类型]线段树 成段增减+区间求和 &题解: 线段树 ...
- POJ 3468 A Simple Problem with Integers(线段树/区间更新)
题目链接: 传送门 A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Description Yo ...
- poj 3468:A Simple Problem with Integers(线段树,区间修改求和)
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 58269 ...
随机推荐
- Pyhon学习笔记-基础3
文件操作 1.基本操作 f = open("filename","r",encoding="utf-8") #打开文件,以r模式,字符编码模 ...
- chat.php
<!DOCTYPE html><html> <meta charset="UTF-8"> <title>web chat</t ...
- 05 详解C# 迭代器
迭代器模式是设计模式中行为模式(behavioral pattern)的一个例子,他是一种简化对象间通讯的模式,也是一种非常容易理解和使用的模式. 简单来说,迭代器模式使得你能够获取到序列中的所有元素 ...
- 代码覆盖率 EclEmma
1. EclEmma的介绍 EclEmma是一个开源的软件测试工具,可以在编码过程中查看代码调用情况.也可以检测单覆盖率. 2. Eclipse下EclEmma安装 1. 选择Help->Ecl ...
- SSM环境的搭建
回顾 首先创建新的项目,选择Maven管理我们的依赖 如图所示: 当然我是为了做列子,所以采用的中文, 然后选择自己的maven地址,这里稍微注意的是,Maven默认读取的是 .m2/setting. ...
- Javascript高级编程学习笔记(70)—— 事件(14)内存和性能
由于事件处理程序是现代的web程序交互能力的提供者 所以在日常实践中,我们免不了要向页面中添加大量的事件处理程序(不管是用于用户交互还是用于统计用户数据) 在创建GUI(图形用户界面)的语言(如C#) ...
- django项目微博第三方登录
此处咱们用到的是 social_django,所以要把此应用注册到配置文件中, INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.a ...
- ansible中include_tasks和import_tasks
简介 本文主要总结下ansible里task调用的方法有哪些和它们的主要区别 随着要管理的服务不断增多,我们又没将task放到roles里,会发现playbook文件越来越大,内容也越来越多,管理起 ...
- oracle select in超过1000条报错解决方法
本博客介绍oracle select in超过1000条数据的解决方法,java框架是采用mybatis的,这可以说是一种比较常见的错误:select * from A where id in(... ...
- mysql原生sql盘点
select*from (select*from test1 union all select*from test2 ) //两个查询的数据行数需要对应一致,且名字as 一致. 1.如果直接用如下sq ...