zoukankan      html  css  js  c++  java
  • BZOJ1432 [ZJOI2009]Function

    Description

    Input

    一行两个整数n; k。

    Output

    一行一个整数,表示n 个函数第k 层最少能由多少段组成。

    Sample Input

    1 1

    Sample Output

    1

    HINT

    对于100% 的数据满足1 ≤ k ≤ n ≤ 100。

     

    正解:数学

    解题报告:

      网上都没有题解,那我也不写了吧。

     1 //It is made by jump~
     2 #include <iostream>
     3 #include <cstdlib>
     4 #include <cstring>
     5 #include <cstdio>
     6 #include <cmath>
     7 #include <algorithm>
     8 #include <ctime>
     9 #include <vector>
    10 #include <queue>
    11 #include <map>
    12 #include <set>
    13 using namespace std;
    14 typedef long long LL;
    15 int n,k,ans;
    16 
    17 inline int getint()
    18 {
    19        int w=0,q=0; char c=getchar();
    20        while((c<'0' || c>'9') && c!='-') c=getchar(); if(c=='-') q=1,c=getchar(); 
    21        while (c>='0' && c<='9') w=w*10+c-'0', c=getchar(); return q ? -w : w;
    22 }
    23 
    24 inline void work(){
    25     n=getint(); k=getint(); if(n==1) ans=1; else ans=min(k,n-k+1)*2;
    26     printf("%d",ans); 
    27 }
    28 
    29 int main()
    30 {
    31   work();
    32   return 0;
    33 }
  • 相关阅读:
    mac 快捷键
    mac 配置nginx 虚拟域名(转载)
    StringUtils中 isNotEmpty 和isNotBlank的区别【java字符串判空】
    软件常用版本英文snapshot和ga
    IF条件控制
    函数与方法
    数据类型
    函数 FUNCTION
    集合 SET
    字典 DICTIONARY
  • 原文地址:https://www.cnblogs.com/ljh2000-jump/p/5870085.html
Copyright © 2011-2022 走看看