游客 Signup | Login
中文 | En

2166 - Dongqi要吃饭

Dongqi不小心把Wangjie给惹毛了,Wangjie就怒出了一题,Dongqi做不出来就不允许吃饭。题目是给定一个边长为2n的正方形,被划分成2n * 2n个小方格。有一个直径为2n-1的圆,圆心与该正方形的中心重合。请问该圆与多少个小方格相交?你们能帮助Dongqi吗?

Input

多组输入样例,每个样例包含一个整数n (n <= 1000)
0表示输入结束

Output

对应每个样例输出一行,每一行包含一个整数ans,表示了对应输入的答案

Examples

Input

1
2
0

Output

4
12

Solution C++

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int a[1005];

int main() {
  //freopen("Dongqi.in", "r", stdin);
	//freopen("Dongqi.out", "w", stdout);
  int n;
  a[1] = 4;
  for (int i = 2; i <= 1000; i++) {
    a[i] = a[i - 1] + 8;
  }
  while (scanf("%d", &n) != EOF) {
    if (n == 0)
      break;
    else
      printf("%d\n", a[n]);
  }
  return 0;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题