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 ...
随机推荐
- 201671010147 2017年8月27号 初学java的感想
在IT行业中,java无疑是最热门的,很多企业也青睐java,因为他的扩展性好,可以处理更多客户的数据,正是因为java有前景所以才吸引更多人去学习.在大一我们已经接触vhleC语言,大二开始就解除了 ...
- Openvswitch手册(7): Interfaces
我们来看Interfaces ofport: OpenFlow port number for this interface. type: system: An ordinary network de ...
- 玩转Kafka的生产者——分区器与多线程
上篇文章学习kafka的基本安装和基础概念,本文主要是学习kafka的常用API.其中包括生产者和消费者, 多线程生产者,多线程消费者,自定义分区等,当然还包括一些避坑指南. 首发于个人网站:链接地址 ...
- ueditor编辑器显示style标签样式
在使用ueditor编辑器中,想保存style标签的样式需要对js配置文件进行修改.官方为了安全考虑,默认会将style标签转为DIV标签,导致样式不能显示出对应的效果. 基于1.4.3版本修改如下 ...
- Jquery+Eayui实现列表选择功能
在做一个列表选择的功能,要实现一个Jquery列表选择器的效果,如图就是很常见的一种列表选择器 不过网上开源的可能要积分,资料没找到合适的,所以自己就简单写了一下,其实实现也不是很难.实现思路:左边双 ...
- java中编写增删改查
按照图书数据库来说 //查询 :查询的返回值有两种类型,如果返回的数据你不确定是一条还是多条就返回一个List集合.如果你确定数据返回的是一条,可以把返回值换成Book实体类型.public List ...
- 最优路径算法合集(附python源码)(原创)
主要的最优(最短)路径算法: 一.深度优先算法:二.广度优先算法:三.Dijstra最短路径:四.floyd最短路径(待): 一.深度优先算法 图的深度优先搜索(Depth First Search) ...
- 《CLR Via C#》读书笔记:24.运行时序列化
一.什么是运行时序列化 序列化的作用就是将对象图(特定时间点的对象连接图)转换为字节流,这样这些对象图就可以在文件系统/网络进行传输. 二.序列化/反序列化快速入门 一般来说我们通过 FCL 提供的 ...
- ubuntu16.04 离线安装docker ce
ubuntu离线安装 docker17.05.0-ce 离线安装 不想自己下载的小伙伴可以从以下地址下载几个软件包: 链接: https://pan.baidu.com/s/1lF7t7ciMhUnW ...
- vue 移动端屏幕适配 使用rem
要想移动端适配 并使用 rem 您需要先看这篇文章,配置好less ➡️ 在vue 中使用 less,就可以使用rem了 如果项目已经开发的差不多了,没有用到rem 又要使用rem,您用这招. po ...