• CaoHaha's staff


    CaoHaha's staff

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 0    Accepted Submission(s): 0


    Problem Description
    "You shall not pass!"
    After shouted out that,the Force Staff appered in CaoHaha's hand.
    As we all know,the Force Staff is a staff with infinity power.If you can use it skillful,it may help you to do whatever you want.
    But now,his new owner,CaoHaha,is a sorcerers apprentice.He can only use that staff to send things to other place.
    Today,Dreamwyy come to CaoHaha.Requesting him send a toy to his new girl friend.It was so far that Dreamwyy can only resort to CaoHaha.
    The first step to send something is draw a Magic array on a Magic place.The magic place looks like a coordinate system,and each time you can draw a segments either on cell sides or on cell diagonals.In additional,you need 1 minutes to draw a segments.
    If you want to send something ,you need to draw a Magic array which is not smaller than the that.You can make it any deformation,so what really matters is the size of the object.
    CaoHaha want to help dreamwyy but his time is valuable(to learn to be just like you),so he want to draw least segments.However,because of his bad math,he needs your help.
     
    Input
    The first line contains one integer T(T<=300).The number of toys.
    Then T lines each contains one intetger S.The size of the toy(N<=1e9).
     
    Output
    Out put T integer in each line ,the least time CaoHaha can send the toy.
     
    Sample Input
    5 1 2 3 4 5
     
    Sample Output
    4 4 6 6 7
    题目好魔性,就是画图,使劲画图,找规律.
    然后打表,然后就A了.
     1 #include <bits/stdc++.h>
     2 #define ll long long int
     3 #define N 1000005
     4 using namespace std;
     5 int k[N];
     6 void fa(){
     7     memset(k,0,sizeof(k));
     8     k[0]=k[1]=0;
     9     for(int i=2;i<N;i++){
    10         if(i%2==0){
    11             k[i]=i/4*2+k[i-2];
    12         }else{
    13             k[i]=(i+1)/4+k[i-1]-1;
    14         }
    15     }
    16 }
    17 int main(){
    18     int n;
    19     fa();
    20     scanf("%d",&n);
    21     while(n--){
    22         int x;
    23         scanf("%d",&x);
    24         for(int i=0;i<N;i++){
    25             if(k[i]>=x){
    26                 printf("%d
    ",i);
    27                 break;
    28             }
    29         }
    30     }
    31     return 0;
    32 }
  • 相关阅读:
    kettle常见问题解决
    kettle 数据库连接中断重置
    笔记本wifi共享给手机 连接连笔记本wifi
    java.sql.SQLException: Io 异常: Connection reset
    ORA-01013:用户请求取消当前的操作
    dubbo 解决Multicast java.net.SocketException: No such device
    linux设置系统日期时间
    dubbo Linux 解决:nc: command not found
    DUBBO本地搭建及小案例
    使用maven编译dubbo,导入eclipse(其他maven开源项目编译类似)
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7397280.html
Copyright © 2020-2023  润新知