• Rectangle 暴力枚举大法


    frog has a piece of paper divided into n rows and m columns. Today, she would like to draw a rectangle whose perimeter is not greater than k.
     
     
    There are 8 (out of 9) ways when n=m=2,k=6
     
    Find the number of ways of drawing.
     
     
     
    枚举长度  然后算出宽度的取值范围  对宽带再进行求合
     
     1 #include <cstdio>
     2 #include <cstring>
     3 #include <queue>
     4 #include <cmath>
     5 #include <algorithm>
     6 #include <set>
     7 #include <iostream>
     8 #include <map>
     9 #include <stack>
    10 #include <string>
    11 #include <vector>
    12 #define pi acos(-1.0)
    13 #define eps 1e-6
    14 #define fi first
    15 #define se second
    16 #define lson l,m,rt<<1
    17 #define rson m+1,r,rt<<1|1
    18 #define bug         printf("******
    ")
    19 #define mem(a,b)    memset(a,b,sizeof(a))
    20 #define fuck(x)     cout<<"["<<x<<"]"<<endl
    21 #define f(a)        a*a
    22 #define sf(n)       scanf("%d", &n)
    23 #define sff(a,b)    scanf("%d %d", &a, &b)
    24 #define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
    25 #define pf          printf
    26 #define FRE(i,a,b)  for(i = a; i <= b; i++)
    27 #define FREE(i,a,b) for(i = a; i >= b; i--)
    28 #define FRL(i,a,b)  for(i = a; i < b; i++)
    29 #define FRLL(i,a,b) for(i = a; i > b; i--)
    30 #define FIN freopen("DATA.txt","r",stdin)
    31 #define lowbit(x)   x&-x
    32 #pragma comment (linker,"/STACK:102400000,102400000")
    33 
    34 using namespace std;
    35 const int maxn = 1e5 + 10;
    36 typedef long long LL;
    37 LL n,m,k;
    38 int main() {
    39     while(~sfff(n,m,k)){
    40         k=k/2;
    41         LL ans=0;
    42         for (int i=1 ;i<=n ;i++) {
    43             if (k-i<=0) break;
    44             LL  a=(n-i+1);
    45             LL  b=min(k-i,m);
    46             LL  c=(m+(m-b+1))*b/2;
    47             ans+=a*c;
    48         }
    49         printf("%lld
    ",ans);
    50     }
    51     return 0;
    52 }
  • 相关阅读:
    深浅拷贝的区别
    vue中动态加载组件
    一些工具软件
    echarts 自传作品入口
    Echarts progress 设置背景颜色
    Echarts柱状图,柱子设置不一样的渐变色
    .net 控制台学习笔记 一、控制台程序的异常捕获
    IdentityServer4实战:自定义用户名和密码校验
    IdentityServer4实战:Token 中返回用户属性
    IdentityServer4实战:持久化 Resource
  • 原文地址:https://www.cnblogs.com/qldabiaoge/p/9416122.html
Copyright © 2020-2023  润新知