A.Snake Filled

“What a boring world!”
Julyed felt so bored that she
began to write numbers on the coordinate paper. She wrote a “0” on the center,
then wrote the follow numbers clockwise, which looked like a snake as
below.

“Damn! I have
fulfilled the paper!”
Julyed was looking
at paper. Suddenly, she began to feel curious.
“What is the nth number on the positive axis of Y
axis?”
She asked tomriddly for the
question. But tomriddly was so busy that he ignored Julyed. So now you have to
solve this problem.

输入

Multiple test
cases.
The first line contains an
integer T (T <= 50), indicating the number of test cases.
Then T lines follows, one line per case. Each line
contains a positive integer n (n <= 3000).

输出

One line per case. An integer
indicates the nth number on the positive axis of Y axis.

样例输入

3
1
2
18

样例输出

5
18
1314

CODE:

#include <stdio.h>

int xun(int n)

{

int i;

if(n==0)

i=0;

else i=xun(n-1)+5+8*(n-1);

return i;

}

int main()

{

int n,i,T,num;

while(scanf("%d",&T)!=EOF)

{

for(i=0;i<T;i++)

{

scanf("%d",&n);

num=xun(n);

printf("%d\n",num);

}

}

return 0;

}
时间: 2024-08-24 19:23:42

A.Snake Filled的相关文章

2101 Problem A Snake Filled

题目描述 “What a boring world!”Julyed felt so bored that she began to write numbers on the coordinate paper. She wrote a “0” on the center, then wrote the follow numbers clockwise, which looked like a snake as below. “Damn! I have fulfilled the paper!”Ju

今天石大比的赛,这道问题 A: Snake Filled主要是队友做出来的,我就简做个记录

“What a boring world!”Julyed felt so bored that she began to write numbers on the coordinate paper. She wrote a “0” on the center, then wrote the follow numbers clockwise, which looked like a snake as below. “Damn! I have fulfilled the paper!”Julyed

CodeForces 510 A. Fox And Snake(模拟啊 )

题目链接:http://codeforces.com/problemset/problem/510/A Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead. A snake is a pattern on a n by m

A - Fox And Snake

Problem description Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead. A snake is a pattern on a n by m table. Denote c-th cell of r-th

Active Snake (Level Set 模型)

前沿:最近由于大论文实验的原因,需要整理几种Snake方法,以比较道路提取效果.所以今天晚上就将电脑中的一些LBF Snake代码作一下分类定义.并给出效果.以便比较. 1. 原始的LBF Snake方法的效果 原始的LBF算法实现如下: 实验的代码下载地址,Download Link.然后在网盘中找到这个目录,然后找到下图所示的文件. 但是,初步测试是不能用,原因是LSE程序的源文件无法编译,找不到源文件.这个代码中提到的参考文献是[1]. 如果需要更加详细的学习,请直接百度学术中下载. 一下

SGU 128.Snake

时间限制:0.25s 空间限制:4m 题意: 在一个平面坐标中有N个点,现在要你用这N个点构造一个闭合图形,这个图形要满足以下条件: 1.这个图形要是闭合的:          2.图形上的点只能是给定的点,且每个点只能用一次:          3.每个顶点相连的两条边必须互相垂直:          4.每条边都要平行于坐标轴:          5.每条线除了顶点外都不能互相相交:          6.闭合图形的周长要最小: N-----点的个数          接下来N个点.    

Light OJ 1168 Wishing Snake 强连通缩点+哈密顿通路

题目来源:Light OJ 1168 Wishing Snake 题意:有点难看懂题意 看了一个小时再加别人的代码才懂意思 从0开始 输入的那些每一对u v 都要经过 就是从0到到达那些点 思路:首先缩点 每一个强连通分量里面的点都是可达的 缩点后的图是有向无环图 如果从0这个强连通分量可以出去到2个强连通分量 那么这两个强连通分量是不可能相互可达 所以可行的方案就是所有的强连通分量连成一线 一个一个串起来 除了第一个 出度是1入度是0和最后一个出度是0入度是1 其他都是入度等于出度是1 特判只

android Snake(3)

添加两个苹果到主界面 Coordinate定义坐标,其中有能够判断是否相等的equals方法,用以判断两个坐标是否相等.MyRandom随机数生成类,封装random能够控制随机数产生的范围,产生随机坐标.SnakeView中判断产生的苹果是否重复,如果重复再产生一个,直到不重复为止. Coordinate.java package edu.hhxy.util; public class Coordinate { public int row; public int column; public

图像分割之(五)活动轮廓模型之Snake模型简介

在"图像分割之(一)概述"中咱们简单了解了目前主流的图像分割方法.下面咱们主要学习下基于能量泛函的分割方法.这里学习下Snake模型简单的知识,Level Set(水平集)模型会在后面的博文中说到. 基于能量泛函的分割方法: 该类方法主要指的是活动轮廓模型(active contour model)以及在其基础上发展出来的算法,其基本思想是使用连续曲线来表达目标边缘,并定义一个能量泛函使得其自变量包括边缘曲线,因此分割过程就转变为求解能量泛函的最小值的过程,一般可通过求解函数对应的欧拉