http://codeforces.com/contest/1072/problem/A

 

题目挺简单,就是让你求几个环,占得方格的个数,然而题目为什么给出了公式呢?

然而给出的公式辣么丑,还是不用的好。

我们看一个$n \times m$的环型,它的占得方个数为$(n+m) \times 2 -4 $

每次换的大小长宽各减4,那么我们计算就好了。

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int n,m,k,ans;
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=k;i++)
    {
        ans+=(n+m)*2;
        n-=4;
        m-=4;
    }
    ans-=k*4;
    printf("%d",ans);
}

 

相关文章:

  • 2022-12-23
  • 2021-08-07
  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2022-02-08
  • 2022-03-01
  • 2021-11-27
猜你喜欢
  • 2021-10-06
  • 2021-09-02
  • 2021-10-23
  • 2021-09-11
  • 2021-05-30
  • 2021-07-07
  • 2021-10-28
相关资源
相似解决方案