Chieh's Blog

Because Of Coding

Hadoop安装常见问题

两个standby 强制启动一个

出现0datanode 删除tmp文件夹,重新启动

zoo.cfg问题  关闭防火墙

ZOJ Problem Set - 2273 Number Sequence III

飞机票:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1273

对于每个回合,求出每个回合第一个数字是多少,则第i回合增量为2^i的等差数列。然后对于位置进行处理,算出当前数字的位置中最大能到达的层数。该层数和前一个数字的层数比较,选出最大的即为答案

//
//  main.cpp
//  zoj2273
//
//  Created by cfhaiteeh on 11/03/2018.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define  LL long long
using namespace std;

int turn[5*123456];
bool vis[5*123456];
int ans[100000];
int tpow[5*123456];
int wzz[100000];
void getTurn(){
    int c=1;
    int now=1;
    int t=2;
    int before=1;
    int z=0;
    while(true){
        now=now^1;
        if(now==0){
            int st=c+before;
            for(int i=st;i<=500000;i+=t){
                vis[i]=1;
            }
            tpow[++z]=t;
            t*=2;
            turn[z]=st;
           
        }else{
            for(int i=c;i<=500000;i+=t){
                vis[i]=1;
            }
            before=t;
            tpow[++z]=t;
            t*=2;
            bool flag=1;
             turn[z]=c;
            for(int i=c;i<=500000;i++){
                if(!vis[i]){
                    c=i;
                    flag=0;
                    break;
                }
            }
           
        
            if(flag)break;
        }
        
    }
  
}
void getAw(){
    ans[1]=1;
    ans[2]=1;
    ans[3]=3;
    wzz[1]=1;
    wzz[2]=1;
    wzz[3]=3;
    int s=3;
    int ci[6];
    for(int i=4;i<=99999;i++){
        int tp=i;
        int op=0;
        int now=-1;
        int ip=ans[i-1];
        int ww=wzz[i-1];
        for(int k=1;k<=500000;k++){
            int a=wzz[i-1]-turn[k];
            if(a<0)continue;
          
            if(a%tpow[k]==0){
                now=k;
                break;
            }
        }
        while(tp>0){
            int c=tp%10;
            ci[++op]=c;
            tp=tp/10;
        }
        for(int j=op;j>=1;j--){
            s++;
            int wz=s;
          
            for(int k=1;k<=500000;k++){
                int a=wz-turn[k];
           
                if(a<0)continue;
                if(a%tpow[k]==0){
                    
                    if(k>now){
                       
                        now=k;
                        ip=ci[j];
                        ww=wz;
                    }
                    break;
                }
            }
           
        }
        ans[i]=ip;
        wzz[i]=ww;
    }
    
}
int main() {
    getTurn();
    getAw();
  //  cout<<"end"<<endl;
    int a;
    while(scanf("%d",&a)!=EOF){
        printf("%d\n",ans[a]);
    }
    return 0;
}

现在起,对于复杂点的题目写题解

人生就是兜兜转转,请相信自己每次的决定

The End ==The Start

退役啦~  还是回来好好做题了。即使到最后一无所有。我至少没放弃我曾经想要的生活。 Update 2015-10-24

Hello_My_new_blog

欢迎光临我的blog,我是Chieh

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <stack>
#define LL long long
int  main()
{
    while(1)
    {
        printf("Welcome to Chieh's Blog\n");
    }
}