今天石大比的赛,这道问题 A: Snake Filled主要是队友做出来的,我就简做个记录
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了今天石大比的赛,这道问题 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).
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.
程序设计:
#include<stdio.h>
#include<math.h>
int main()
{
int a,b;
int s;
int t;
while(scanf("%d",&a)!=EOF) {
int i;
for(i=0;i<a;i++){
scanf("%d",&b);
s=pow(b+b+1,2);
t=s-(b+b+1)-(b+b+1)/2;
printf("%d\n",t);
}
}
return 0;
}
#include<math.h>
int main()
{
int a,b;
int s;
int t;
while(scanf("%d",&a)!=EOF) {
int i;
for(i=0;i<a;i++){
scanf("%d",&b);
s=pow(b+b+1,2);
t=s-(b+b+1)-(b+b+1)/2;
printf("%d\n",t);
}
}
return 0;
}
以上是关于今天石大比的赛,这道问题 A: Snake Filled主要是队友做出来的,我就简做个记录的主要内容,如果未能解决你的问题,请参考以下文章