zoukankan      html  css  js  c++  java
  • 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
    ",a)
    #define write2(a,b)     printf("%d %d
    ",a,b)
    #define write3(a,b,c)   printf("%d %d %d
    ",a,b,c)
    #pragma comment         (linker,"/STACK:102400000,102400000")
    template<class T> inline T L(T a)       {return (a << 1);}
    template<class T> inline T R(T a)       {return (a << 1 | 1);}
    template<class T> inline T lowbit(T a)  {return (a & -a);}
    template<class T> inline T Mid(T a,T b) {return ((a + b) >> 1);}
    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 = 1,y = 0,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 >> 1 & 0x55555555) | ((x << 1) & 0xaaaaaaaa); x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);
        x = (x >> 4 & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0); x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);
        x = (x >>16 & 0x0000ffff) | ((x <<16) & 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 = 0;
                cin>>n;
                if(n == 1){
                    cout<<"0"<<endl;
                    continue;
                }
                LL tmp = res = n;
                for(LL i = 2 ; i <= n ; i++){
                    if(tmp - n/i <= 1) {
                        res -= tmp;
                        break;
                    }
                    res += n/i;
                    tmp = n/i;
                }
                LL t = n;
                for(LL i = 1 ; i <= tmp ; i++){
                    res += (t - n/(i+1)) * i ;
                    t = n/(i+1);
                }
                res -= n;
                cout<<res<<endl;
            }
        }
        return 0;
    }
  • 相关阅读:
    DataTable 中varchar 转换为 Double 后重新 排序。
    asp.net 后台实现删除,划掉效果
    word2007二级标题自动编号不从大标题开始的解决方法
    asp.net 多个文件同时下载
    asp 时间倒数后按钮可用
    js获取gridview模板列中textbox行列的值
    JS错误 theForm.submit();SCRIPT3: 找不到成员。
    JS验证 只能输入小数点,数字,负数。
    关于SQLServer2008数据如何导入SQL2005的解决办法,高版本数据导入低版本中。
    asp.net中TreeView的大数据加载速度优化
  • 原文地址:https://www.cnblogs.com/Felix-F/p/3354575.html
Copyright © 2011-2022 走看看