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;
    }
  • 相关阅读:
    详细版Jmeter随机参数的接口并发测试总结
    Windows下MQTT代理服务器的搭建
    关于使用elascticsearch的两个小技巧
    解决easyswoole的swServer_start_check: onTask event callback must be set at报错
    解决使用宝塔安装的swoole扩展,运行项目出现的3个常见问题
    浅谈一下ThinkPHP5.1实现事务嵌套的特性
    资源出现多个 "Access-Control-Allow-Origin"
    Mac 制作系统启动盘
    深入剖析分布式一致性共识算法
    分布式系统限流算法分析与实现
  • 原文地址:https://www.cnblogs.com/Felix-F/p/3354575.html
Copyright © 2011-2022 走看看