zoukankan      html  css  js  c++  java
  • ZOJ4125 Sekiro

    犹豫就会败北!!

    给出两个数n,k 对n进行[n/2](向上取整)k次 注意n为1时跳出就行了(我有个队友没写这个跳出条件 用二重循环 直接TLE了

    AC代码:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 typedef unsigned long long ull;
     5 
     6 int t, n, k;
     7 
     8 int main(){
     9     cin>>t;
    10     while (t--){
    11         cin>>n>>k;
    12         while (n > 1 && k){
    13             n = (n + 1) / 2;
    14             k--;
    15         }
    16         cout<<n<<endl;
    17     }
    18     return 0;
    19 }
  • 相关阅读:
    git命令
    Linux基础知识手册
    Linux系统编程
    A
    Subsequences in Substrings Kattis
    G
    K
    K
    C
    E
  • 原文地址:https://www.cnblogs.com/Misuchii/p/10896962.html
Copyright © 2011-2022 走看看