• Codeforces Round #662 (Div. 2) A


    题面

    One evening Rainbow Dash and Fluttershy have come up with a game. Since the ponies are friends, they have decided not to compete in the game but to pursue a common goal.

    The game starts on a square flat grid, which initially has the outline borders built up. Rainbow Dash and Fluttershy have flat square blocks with size 1×1, Rainbow Dash has an infinite amount of light blue blocks, Fluttershy has an infinite amount of yellow blocks.

    The blocks are placed according to the following rule: each newly placed block must touch the built on the previous turns figure by a side (note that the outline borders of the grid are built initially). At each turn, one pony can place any number of blocks of her color according to the game rules.

    Rainbow and Fluttershy have found out that they can build patterns on the grid of the game that way. They have decided to start with something simple, so they made up their mind to place the blocks to form a chess coloring. Rainbow Dash is well-known for her speed, so she is interested in the minimum number of turns she and Fluttershy need to do to get a chess coloring, covering the whole grid with blocks. Please help her find that number!

    Since the ponies can play many times on different boards, Rainbow Dash asks you to find the minimum numbers of turns for several grids of the games.

    The chess coloring in two colors is the one in which each square is neighbor by side only with squares of different colors.

    Input
    The first line contains a single integer T (1≤T≤100): the number of grids of the games.

    Each of the next T lines contains a single integer n (1≤n≤109): the size of the side of the grid of the game.

    Output
    For each grid of the game print the minimum number of turns required to build a chess coloring pattern out of blocks on it.

    Example
    inputCopy
    2
    3
    4
    outputCopy
    2
    3

    思路

    刚开始读错了,吐。用手画一下五的情况和四的情况,并且用聪明的小脑袋想一下,这个是个奇偶规律题。

    代码实现

    #include<cstdio>
    #include<algorithm>
    #include<vector>
    #include<queue>
    #include<map>
    #include<iostream>
    #include<cstring>
    #include<cmath>
    using namespace std;
    #define rep(i,f_start,f_end) for (int i=f_start;i<=f_end;++i)
    #define per(i,n,a) for (int i=n;i>=a;i--)
    #define MT(x,i) memset(x,i,sizeof(x) )
    #define rev(i,start,end) for (int i=0;i<end;i++)
    #define inf 0x3f3f3f3f
    #define mp(x,y) make_pair(x,y)
    #define lowbit(x) (x&-x)
    #define MOD 1000000007
    #define exp 1e-8
    #define N 1000005 
    #define fi first 
    #define se second
    #define pb push_back
    typedef long long ll;
    typedef pair<int ,int> PII;
    ll gcd (ll a,ll b) {return b?gcd (b,a%b):a; }
    inline int read() {
        char ch=getchar(); int x=0, f=1;
        while(ch<'0'||ch>'9') {
            if(ch=='-') f = -1;
            ch=getchar();
        } 
        while('0'<=ch&&ch<='9') {
            x=x*10+ch-'0';
            ch=getchar();
        }   return x*f;
    }
     
     
     
    int main () {
    //    freopen ("data.in","r",stdin);
       int t;
       cin>>t;
       while (t--) {
           int n;
           cin>>n;
           if (n%2==1) cout<<n-n/2<<endl;
           else cout<<n-n/2+1<<endl;
       }
    //    fclose (stdin);
       return 0;
    }
    
  • 相关阅读:
    游戏中战斗伤害范围-弹道飞行
    游戏中战斗伤害范围攻击计算完整全版
    更加强健的线程模型,解决线程卡死,退出异常情况
    存在即合理,重复轮子orm java版本
    游戏里12方向,任意方向计算正前方矩形规则
    我是如何设计游戏服务器架构的
    游戏中精灵对象的属性功能设计
    看我是如何处理自定义线程模型---java
    面试和面试者如何保持心态
    谈谈枚举的新用法——java
  • 原文地址:https://www.cnblogs.com/hhlya/p/13457621.html
Copyright © 2020-2023  润新知