ZOJ 3175 Number of Containers 分块
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3216
乱搞的...watashi是分块做的...但我并不知道什么是分块...大概就是把结果相同的数据合并计算
打表跑了一下...发现重复出现的数字很多...于是直接找出会发生重复的数乘起来就行了...
/********************* Template ************************/
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define EPS 1e-8
#define DINF 1e15
#define MAXN 1000050
#define MOD 1000000007
#define INF 0x7fffffff
#define LINF 1LL<<60
#define PI 3.14159265358979323846
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define BUG cout<<" BUG! "<<endl;
#define LINE cout<<" ------------------ "<<endl;
#define FIN freopen("in.txt","r",stdin);
#define FOUT freopen("out.txt","w",stdout);
#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,a,b) for(int i = a ; i < b ; i++)
#define read(a) scanf("%d",&a)
#define read2(a,b) scanf("%d%d",&a,&b)
#define read3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define write(a) printf("%d\n",a)
#define write2(a,b) printf("%d %d\n",a,b)
#define write3(a,b,c) printf("%d %d %d\n",a,b,c)
#pragma comment (linker,"/STACK:102400000,102400000")
template<class T> inline T L(T a) {return (a << );}
template<class T> inline T R(T a) {return (a << | );}
template<class T> inline T lowbit(T a) {return (a & -a);}
template<class T> inline T Mid(T a,T b) {return ((a + b) >> );}
template<class T> inline T gcd(T a,T b) {return b ? gcd(b,a%b) : a;}
template<class T> inline T lcm(T a,T b) {return a / gcd(a,b) * b;}
template<class T> inline T Min(T a,T b) {return a < b ? a : b;}
template<class T> inline T Max(T a,T b) {return a > b ? a : b;}
template<class T> inline T Min(T a,T b,T c) {return min(min(a,b),c);}
template<class T> inline T Max(T a,T b,T c) {return max(max(a,b),c);}
template<class T> inline T Min(T a,T b,T c,T d) {return min(min(a,b),min(c,d));}
template<class T> inline T Max(T a,T b,T c,T d) {return max(max(a,b),max(c,d));}
template<class T> inline T exGCD(T a, T b, T &x, T &y){
if(!b) return x = ,y = ,a;
T res = exGCD(b,a%b,x,y),tmp = x;
x = y,y = tmp - (a / b) * y;
return res;
}
template<class T> inline T reverse_bits(T x){
x = (x >> & 0x55555555) | ((x << ) & 0xaaaaaaaa); x = ((x >> ) & 0x33333333) | ((x << ) & 0xcccccccc);
x = (x >> & 0x0f0f0f0f) | ((x << ) & 0xf0f0f0f0); x = ((x >> ) & 0x00ff00ff) | ((x << ) & 0xff00ff00);
x = (x >> & 0x0000ffff) | ((x <<) & 0xffff0000); return x;
}
typedef long long LL; typedef unsigned long long ULL;
//typedef __int64 LL; typedef unsigned __int64 ULL; /********************* By F *********************/
int main(){
//FIN;
//FOUT;
int T;
while(cin>>T){
while(T--){
LL n,res = ;
cin>>n;
if(n == ){
cout<<""<<endl;
continue;
}
LL tmp = res = n;
for(LL i = ; i <= n ; i++){
if(tmp - n/i <= ) {
res -= tmp;
break;
}
res += n/i;
tmp = n/i;
}
LL t = n;
for(LL i = ; i <= tmp ; i++){
res += (t - n/(i+)) * i ;
t = n/(i+);
}
res -= n;
cout<<res<<endl;
}
}
return ;
}
ZOJ 3175 Number of Containers 分块的更多相关文章
- Number of Containers ZOJ - 3175(数论题)
Problem Description For two integers m and k, k is said to be a container of m if k is divisible by ...
- Number of Containers(数学) 分类: 数学 2015-07-07 23:42 1人阅读 评论(0) 收藏
Number of Containers Time Limit: 1 Second Memory Limit: 32768 KB For two integers m and k, k is said ...
- ZOJ 3908 Number Game ZOJ Monthly, October 2015 - F
Number Game Time Limit: 2 Seconds Memory Limit: 65536 KB The bored Bob is playing a number game ...
- [ZOJ 2836] Number Puzzle
Number Puzzle Time Limit: 2 Seconds Memory Limit: 65536 KB Given a list of integers (A1, A2, .. ...
- zoj Beautiful Number(打表)
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829 题目描述: Mike is very lucky, as ...
- ZOJ 1414:Number Steps
Number Steps Time Limit: 2 Seconds Memory Limit: 65536 KB Starting from point (0,0) on a plane, ...
- ZOJ 3596Digit Number(BFS+DP)
一道比较不错的BFS+DP题目 题意很简单,就是问一个刚好包含m(m<=10)个不同数字的n的最小倍数. 很明显如果直接枚举每一位是什么这样的话显然复杂度是没有上限的,所以需要找到一个状态表示方 ...
- ZOJ 3180 Number Game(模拟,倒推)
题目 思路: 先倒推!到最后第二步,然后: 初始状态不一定满足这个状态.所以我们要先从初始状态构造出它出发的三种状态.那这三种状态跟倒推得到的状态比较即可. #include<stdio.h&g ...
- ZOJ 2836 Number Puzzle 题解
题面 lcm(x,y)=xy/gcd(x,y) lcm(x1,x2,···,xn)=lcm(lcm(x1,x2,···,xn-1),xn) #include <bits/stdc++.h> ...
随机推荐
- Java里的各种队列
以下翻译来自java8的官方文档: 1.LinkedBlockingQueue:基于链接节点的可选限定的blocking queue . 这个队列排列元素FIFO(先进先出). 队列的头部是队列中最长 ...
- hdu_1754,线段树单点更新,求区间最值
http://www.notonlysuccess.com/index.php/segment-tree-complete/ #include<iostream> #include< ...
- BZOJ 4448 主席树+树链剖分(在线)
为什么题解都是离线的-- (抄都没法抄) 搞一棵主席树 1 操作 新树上的当前节点设成1 2 操作 查max(i-xx-1,0)那棵树上这条路径上有多少个点是1 让你找经过了多少个点 查的时候用dee ...
- 单表的更新UPDATE和删除记录DELETE(二十六)
当把记录写成功之后,也许我们还会如下操作.比如,记录在书写的过程中字段是错误的.或者,我们想改下字段值.那么,我们需要update关键字. update分为单表更新和多表更新. 一.UPDATE语句 ...
- zookeeper伪分布安装配置
1.下载路径为:http://mirrors.cnnic.cn/apache/zookeeper/stable/ 2.安装: 第一步 解压zookeeper压缩包: 进入 zookeeper安装目录 ...
- Android TabLayout添加自定义分割线并且可以修改分割线高度
为TabLayout添加分割线,显示的效果如下(红框内部分): 分割线 首先添加个竖线xml名为layout_divider_vertical: LinearLayout linearLayout = ...
- Android textView开头空两格问题,排版缩进2个汉字
一般为了排版,textView中字符段落开头一般都会空两格显示,如下图 但是如果你靠敲击空格来解决那就错了,那样在不同的屏幕上显示会差异,完美的解决方法是用转义字符”\t“,在段首加\t\t就解决.加 ...
- 由浅入深讲解数据库中Synonym的使用方法
1.Synonym的概念 Synonym(同义词)是SQL Server 2005的新特性.推出已经有几年的时间了.我们可以简单的理解Synonym为其他表的别名.本文中使用Northwind数据库为 ...
- java必会的英语单词
Java开发常用英语单词表 第一章:public['pʌblik] 公共的,公用的static['stætik] 静的;静态的;静止的void:[vɔid] 空的main:[mein] 主要的 重 ...
- [HAOI2016]找相同字符 广义后缀自动机_统计出现次数
题目描述:给定两个字符串,求出在两个字符串中各取出一个子串使得这两个子串相同的方案数.两个方案不同当且仅当这两个子串中有一个位置不同. 输入输出格式输入格式:两行,两个字符串 s1,s2,长度分别为n ...