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 ...
随机推荐
- 卷积神经网络中的channel 和filter
在深度学习的算法学习中,都会提到 channels 这个概念.在一般的深度学习框架的 conv2d 中,如 tensorflow .mxnet,channels 都是必填的一个参数. channels ...
- python爬虫学习之正则表达式的基本使用
一.正则表达式 1. 正则表达式是字符串处理的有力工具和技术. 2. 正则表达式使用某种预定义的模式去匹配一类具有共同特征的字符串,主要用于处理字符串,可以快速.准确地完成复杂的查找.替换等处理要求, ...
- Ubuntu 16.04安装Notepadqq编辑器替代Notepad++
Notepad++只有Windows平台产品,对于Linux下有其替代的产品Notepadqq. 安装: sudo add-apt-repository ppa:notepadqq-team/note ...
- Group By Rollup
Rollup与group by组合使用,可对分组结果进行进一步的汇总. 创建数据表 select * from emp_test (1) rollup单个字段 如按照country字段进行分组,并在最 ...
- flink-kafka-connector 的实现
简单介绍 flink-kafka-connector用来连接kafka,用于消费kafka的数据, 并传入给下游的算子. 使用方式 首先来看下flink-kafka-connector的简单使用, 在 ...
- getComputedStyle与currentStyle获取样式
转载自:https://segmentfault.com/a/1190000007477785 CSS的样式分为三类: 内嵌样式:是写在标签里面的,内嵌样式只对所在的标签有效内部样式:是写在HTML里 ...
- [Leetcode]895.最大频率栈
Problem 实现 FreqStack,模拟类似栈的数据结构的操作的一个类. FreqStack 有两个函数: push(int x),将整数 x 推入栈中. pop(),它移除并返回栈中出现最频繁 ...
- mybatis框架(3)---SqlMapConfig.xml解析
SqlMapConfig.xml SqlMapConfig.xml是Mybatis的全局配置参数,关于他的具体用的有专门的MyBatis - API文档,这里面讲的非常清楚,所以我这里就挑几个讲下: ...
- [android]__如何在studio中导入,使用开源的UI组件
前言 在编程开发中,我们对第三方的优质开源组件是十分依赖的,在很多时候,我们都会使用到他们.使用第三方开源组件能够给我们的编程开发带来很大的便利.今天以这篇文章记录关于在android项目中引用第三方 ...
- PHP实现螺旋矩阵(螺旋数组)
今天碰到一个比较有意思的问题, 就是把A到Y这25个字母以下面的形式输出出来 A B C D E P Q R S F O X Y T G N W V U H M L K J I 问题很有意思,就是转圈 ...