Codeforces 517 #A

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);
}

 

posted @ 2018-10-21 20:28  Manjusaka丶梦寒  阅读(159)  评论(1编辑  收藏  举报