http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3216

乱搞的...watashi是分块做的...但我并不知道什么是分块...大概就是把结果相同的数据合并计算

打表跑了一下...发现重复出现的数字很多...于是直接找出会发生重复的数乘起来就行了...

  1. /********************* Template ************************/
  2. #include <set>
  3. #include <map>
  4. #include <list>
  5. #include <cmath>
  6. #include <ctime>
  7. #include <deque>
  8. #include <queue>
  9. #include <stack>
  10. #include <bitset>
  11. #include <cstdio>
  12. #include <string>
  13. #include <vector>
  14. #include <cassert>
  15. #include <cstdlib>
  16. #include <cstring>
  17. #include <sstream>
  18. #include <fstream>
  19. #include <numeric>
  20. #include <iomanip>
  21. #include <iostream>
  22. #include <algorithm>
  23. #include <functional>
  24. using namespace std;
  25. #define EPS 1e-8
  26. #define DINF 1e15
  27. #define MAXN 1000050
  28. #define MOD 1000000007
  29. #define INF 0x7fffffff
  30. #define LINF 1LL<<60
  31. #define PI 3.14159265358979323846
  32. #define lson l,m,rt<<1
  33. #define rson m+1,r,rt<<1|1
  34. #define BUG cout<<" BUG! "<<endl;
  35. #define LINE cout<<" ------------------ "<<endl;
  36. #define FIN freopen("in.txt","r",stdin);
  37. #define FOUT freopen("out.txt","w",stdout);
  38. #define mem(a,b) memset(a,b,sizeof(a))
  39. #define FOR(i,a,b) for(int i = a ; i < b ; i++)
  40. #define read(a) scanf("%d",&a)
  41. #define read2(a,b) scanf("%d%d",&a,&b)
  42. #define read3(a,b,c) scanf("%d%d%d",&a,&b,&c)
  43. #define write(a) printf("%d\n",a)
  44. #define write2(a,b) printf("%d %d\n",a,b)
  45. #define write3(a,b,c) printf("%d %d %d\n",a,b,c)
  46. #pragma comment (linker,"/STACK:102400000,102400000")
  47. template<class T> inline T L(T a) {return (a << );}
  48. template<class T> inline T R(T a) {return (a << | );}
  49. template<class T> inline T lowbit(T a) {return (a & -a);}
  50. template<class T> inline T Mid(T a,T b) {return ((a + b) >> );}
  51. template<class T> inline T gcd(T a,T b) {return b ? gcd(b,a%b) : a;}
  52. template<class T> inline T lcm(T a,T b) {return a / gcd(a,b) * b;}
  53. template<class T> inline T Min(T a,T b) {return a < b ? a : b;}
  54. template<class T> inline T Max(T a,T b) {return a > b ? a : b;}
  55. template<class T> inline T Min(T a,T b,T c) {return min(min(a,b),c);}
  56. template<class T> inline T Max(T a,T b,T c) {return max(max(a,b),c);}
  57. template<class T> inline T Min(T a,T b,T c,T d) {return min(min(a,b),min(c,d));}
  58. template<class T> inline T Max(T a,T b,T c,T d) {return max(max(a,b),max(c,d));}
  59. template<class T> inline T exGCD(T a, T b, T &x, T &y){
  60. if(!b) return x = ,y = ,a;
  61. T res = exGCD(b,a%b,x,y),tmp = x;
  62. x = y,y = tmp - (a / b) * y;
  63. return res;
  64. }
  65. template<class T> inline T reverse_bits(T x){
  66. x = (x >> & 0x55555555) | ((x << ) & 0xaaaaaaaa); x = ((x >> ) & 0x33333333) | ((x << ) & 0xcccccccc);
  67. x = (x >> & 0x0f0f0f0f) | ((x << ) & 0xf0f0f0f0); x = ((x >> ) & 0x00ff00ff) | ((x << ) & 0xff00ff00);
  68. x = (x >> & 0x0000ffff) | ((x <<) & 0xffff0000); return x;
  69. }
  70. typedef long long LL; typedef unsigned long long ULL;
  71. //typedef __int64 LL; typedef unsigned __int64 ULL;
  72.  
  73. /********************* By F *********************/
  74. int main(){
  75. //FIN;
  76. //FOUT;
  77. int T;
  78. while(cin>>T){
  79. while(T--){
  80. LL n,res = ;
  81. cin>>n;
  82. if(n == ){
  83. cout<<""<<endl;
  84. continue;
  85. }
  86. LL tmp = res = n;
  87. for(LL i = ; i <= n ; i++){
  88. if(tmp - n/i <= ) {
  89. res -= tmp;
  90. break;
  91. }
  92. res += n/i;
  93. tmp = n/i;
  94. }
  95. LL t = n;
  96. for(LL i = ; i <= tmp ; i++){
  97. res += (t - n/(i+)) * i ;
  98. t = n/(i+);
  99. }
  100. res -= n;
  101. cout<<res<<endl;
  102. }
  103. }
  104. return ;
  105. }

ZOJ 3175 Number of Containers 分块的更多相关文章

  1. 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  ...

  2. 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 ...

  3. 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 ...

  4. [ZOJ 2836] Number Puzzle

    Number Puzzle Time Limit: 2 Seconds      Memory Limit: 65536 KB Given a list of integers (A1, A2, .. ...

  5. zoj Beautiful Number(打表)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829 题目描述: Mike is very lucky, as ...

  6. ZOJ 1414:Number Steps

    Number Steps Time Limit: 2 Seconds      Memory Limit: 65536 KB Starting from point (0,0) on a plane, ...

  7. ZOJ 3596Digit Number(BFS+DP)

    一道比较不错的BFS+DP题目 题意很简单,就是问一个刚好包含m(m<=10)个不同数字的n的最小倍数. 很明显如果直接枚举每一位是什么这样的话显然复杂度是没有上限的,所以需要找到一个状态表示方 ...

  8. ZOJ 3180 Number Game(模拟,倒推)

    题目 思路: 先倒推!到最后第二步,然后: 初始状态不一定满足这个状态.所以我们要先从初始状态构造出它出发的三种状态.那这三种状态跟倒推得到的状态比较即可. #include<stdio.h&g ...

  9. 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> ...

随机推荐

  1. Datazen图表创建和公布

     Datazen是被微软收购的移动端全平台的数据展现解决方式.此篇主要介绍怎样创建和公布图表. 如前面介绍,Datazen图表的创建和公布是通过Publisher的应用,它是Windows 8应用 ...

  2. php中命名空间和use

    php中命名空间和use 总结 php中的namespace就有点像java中package包的概念 php中的use的概念就是用别人的命名空间中的类 php中的include enquire是引入文 ...

  3. [JSOI2008] [BZOJ1567] Blue Mary的战役地图 解题报告 (hash)

    题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1567 Description Blue Mary最近迷上了玩Starcraft(星际争霸 ...

  4. 机器学习规则:ML工程最佳实践----rule_of_ml section 3【翻译】

    作者:黄永刚 ML Phase III: 缓慢提升.精细优化.复杂模型 第二阶段就已经接近结束了.首先你的月收益开始减少.你开始要在不同的指标之间做出平衡,你会发现有的涨了而有的却降了.事情变得有趣了 ...

  5. PostgreSQL Replication之第三章 理解即时恢复(2)

    3.2 归档事务日志 看过图片之后,我们可以看看如何使这些东西进入工作状态.当谈到及时归档时,您需要做的第一件事是归档XLOG.PostgreSQL通过postgresql.conf提供了所有与归档相 ...

  6. c#中debug和release版本的区别

    1 debug版本称为调试版本,包含各种调试信息,以为开发人员提供强大的应用程序调试能力,其没有做任何优化,速度慢. 2 release版本称为发布版本,不保存调试信息,但是做了各种的优化,体积小,运 ...

  7. 瞎折腾-CentOS 7.4 编译4.16.2版kernel 并安装

    CentOS 7.4下 原内核版本: 3.10.0-693.el7.x86_64 改后内核版本: 4.16.2 系统版本: CentOS-7-x86_64-Minimal-1708.iso 运行环境: ...

  8. Linux企业运维人员最常用150个命令汇

    近来老男孩发现新手学习Linux记不住命令,不会分类.不会筛选重点,胡子眉毛一把抓当然记不住了. 特别整理Linux运维最常用150个命令和大家分享,大家学习命令不用在盲目了,根据分类,然后逐步学习! ...

  9. 链表python

    无序链表.有序链表 有序列表排序通常是升序或降序,并且我们假设列表项具有已经定义的有意义的比较运算. 许多有序列表操作与无序列表的操作相同. 必须明确链表的第一项位置,一旦知道第一项. 链表实现的基本 ...

  10. 洛谷P2839 [国家集训队]middle 主席树_二分

    Code: #include <cstdio> #include <algorithm> #include <cstring> #include <strin ...