| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2148 人关注过本帖
标题:[讨论]]第十五期编程题目
取消只看楼主 加入收藏
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
 问题点数:0 回复次数:10 
[讨论]]第十五期编程题目
Palindrome Numbers

Time limit: 1 Seconds Memory limit: 32768K
Total Submit: 1508 Accepted Submit: 561

A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, the name "anna" is a palindrome. Numbers can also be palindromes (e.g. 151 or 753357). Additionally numbers can of course be ordered in size. The first few palindrome
numbers are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, ...

The number 10 is not a palindrome (even though you could write it as 010) but a zero as leading digit is not allowed.


Input

The input consists of a series of lines with each line containing one integer value i (1<= i <= 2*10^9 ). This integer value i indicates the index of the palindrome number that is to be written to the output, where index 1 stands for the first palindrome number (1), index 2 stands for the second palindrome number (2) and so on. The input is terminated by a line containing 0.


Output

For each line of input (except the last one) exactly one line of output containing a single (decimal) integer value is to be produced. For each input value i the i-th palindrome number is to be written to the output.


Sample Input

1
12
24
0


Sample Output

1
33
151

/*简单翻译一下,把回文数字从小到大排列.输入n输出对应第n个回文数字 */


Visible Lattice Points

Time limit: 1 Seconds Memory limit: 32768K
Total Submit: 740 Accepted Submit: 352

A lattice point (x, y) in the first quadrant (x and y are integers greater than or equal to 0), other than the origin, is visible from the origin if the line from (0, 0) to (x, y) does not pass through any other lattice point. For example, the point (4, 2) is not visible since the line from the origin passes through (2, 1). The figure below shows the points (x, y) with 0 <= x, y <= 5 with lines from the origin to the visible points.

Write a program which, given a value for the size, N, computes the number of visible points (x,y) with 0 <= x, y <= N.

Input

The first line of input contains a single integer C, (1 <= C <= 1000) which is the number of datasets that follow.

Each dataset consists of a single line of input containing a single integer N, (1 <= N <= 1000), which is the size.

Output

For each dataset, there is to be one line of output consisting of: the dataset number starting at 1, a single space, the size, a single space and the number of visible points for that size.

Sample Input

4
2
4
5
231

Sample Output

1 2 5
2 4 13
3 5 21
4 231 32549

/*输入一个数字n代表一个方格的宽度.方格的左下角是原点,方格中点的坐标都是整数.如果方格中有某个点与原点的连线不经过另外的点则称做这一点是可以从原点看见的.
输入 n
输出 可以看见点的个数.


最近发现论坛上有很多人在ZJU上做题目所以发了这两个题目.
大家可以把自己代码到下面地址去提交测试.
http://acm.zju.edu.cn/show_problem.php?pid=2000
http://acm.zju.edu.cn/show_problem.php?pid=2777
鼓励写的好的发上来让大家学习.没有通过的也可以发上来让大家一起来找出错误.

另外如果有愿意发每期题目的人请和我说一下

搜索更多相关主题的帖子: 编程 example numbers course 
2007-05-18 17:06
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 

没有人做难道是太简单了.
做出一个我给100,
两个都对的给300.
大家加油啊!

2007-05-18 21:01
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 
回复:(herbert_1987)下面是我编的解决第一个问题的...

这样算答案肯定是没有错.
但是首先时间是没有办法在1000MS.
其次就是如果输入的是2000000000的话这个结果可能没有办法用一个数据类型来表示


2007-05-18 22:18
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 
仔细想想就明白了.
不要想把那个数字用一个数字来表示

2007-05-18 22:34
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 
我提示一下.
既然是回文所以只要记录一半就可以了

2007-05-19 08:36
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 
回复:(leeco)2000我纯推数学公式过了……,连我自己...
你推出的数学公式是什么?

你说出来让大家一起来学习一下

2007-05-20 09:25
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 
以下是引用jiangzw625在2007-5-19 23:00:43的发言:

对。11楼说的对。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void Reverse(char* buf)
{
int i,len = strlen(buf);
char ch;
for(i = 0;i<len/2;i++)
{
ch = buf[i];
buf[i] = buf[len-i-1];
buf[len-i-1] = ch;
}
}

int main()
{
int index,num,temp;
char buf[50];
while(scanf("%d",&index) && index)
{
if(index > 108)
{
num = index-99;
_itoa(num,buf,10);
Reverse(buf);
printf("%d%s\n",num,buf);
}
else
{
if(index<10)
printf("%d\n",index);
else if(index<19)
printf("%d%d\n",index-9,index-9);
else
{
index-=19;
num = index/10+1;
temp = index%10;
printf("%d%d%d\n",num,temp,num);
}
}
}
return 0;
}


答案不正确.样例输出都没有对.思路不对.不知道你是不是把题目看错了


2007-05-20 09:30
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 

过了的 也把自己的贴出来让大家学习一下


2007-05-20 09:31
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 
你输入231的时候似乎不对

2007-05-20 11:08
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 
回复:(leeco)ZJU2000的CODE[code]//2007-05-20 00:...
2000我和你差不多.都是发现数列
回文的位数 1 2 3 4 5 6...
回文个数 9 9 90 90 900 900....
2777我比你好一点.我用的是f(n)=f(n-1)+n组数字判断互质

2007-05-20 21:24
快速回复:[讨论]]第十五期编程题目
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013680 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved