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 ...
随机推荐
- CTF中文件包含的一些技巧
i春秋作家:lem0n 原文来自:浅谈内存取证 0x00 前言 网络攻击内存化和网络犯罪隐遁化,使部分关键数字证据只存在于物理内存或暂存于页面交换文件中,这使得传统的基于文件系统的计算机取证不能有效应 ...
- eclipse创建Maven web项目的步骤
Maven 是一个项目管理工具,可以对 Java 项目进行构建.依赖管理. Maven 能够帮助开发者完成以下工作: 构建 文档生成 报告 依赖 SCMs 发布 分发 邮件列表 一.环境配置 Mave ...
- Memcached详解
Memcached介绍 Memcached是什么? Free & open source, high-performance, distributed memory object cachin ...
- Java面试集合(六)
1. abstract抽象 什么是abstract,中文为抽象,从具体事物抽出,概括它们共同的方面,本质属性与关系等,称为抽象.看不见,摸不着的东西叫做抽象,抽象是人们对世界万物的感觉,用特定的图像表 ...
- less编译工具——koala使用介绍
1:使用koala编译软件 官网:http://koala-app.com/index-zh.html (目前官网点击下载没有反应,有人说可能是网络问题,但真正的原因是需要FQ才能下载了) 百度 ...
- flash中调用XML遇到的中文显示异常问题
昨天使用flash调用XML文件进行显示时,出现了中文无法显示的问题,记录一下解决方法: 1.字体设置: 一般flash里的动态文本和嵌入文本都是默认的使用Arial字体,这个字体里可能没有中文,所以 ...
- ubuntu 16.04 安装cuda的方法
很多神经网络架构都需要安装CUDA,安装这个的确费了我不少时间,是要总结一下流程了. 安装这个,最好使用官网的安装步骤和流程,不然,会走很多弯路: https://developer.nvidia.c ...
- Axure安装、破解、汉化全套
最近公司准备使用敏捷开发流程,然后刚好需要Axure这个软件,就去找了些资源分享给大家,希望对大家有所帮助: 全套安装,破解,汉化下载地址: 链接: https://pan.baidu.com/s/1 ...
- Oracle nal() 和count(*)的注意点
select count(*) into fhave from tab_ppxuser where name = userstr;和select nvl(hphotourl, '0') into ph ...
- 运维笔记--ubuntu rm删除文件后 恢复
待补充 特别注意:umount分区,尝试恢复文件,文件夹(目录),全部文件 https://www.cnblogs.com/wangxiaoqiangs/p/5630288.html https:// ...