UVA 138 Street Numbers
来源:互联网 发布:婚礼相册mv制作软件 编辑:程序博客网 时间:2024/06/10 09:00
Description
Street Numbers
A computer programmer lives in a street with houses numbered consecutively (from 1) down one side of the street. Every evening she walks her dog by leaving her house and randomly turning left or right and walking to the end of the street and back. One night she adds up the street numbers of the houses she passes (excluding her own). The next time she walks the other way she repeats this and finds, to her astonishment, that the two sums are the same. Although this is determined in part by her house number and in part by the number of houses in the street, she nevertheless feels that this is a desirable property for her house to have and decides that all her subsequent houses should exhibit it.
Write a program to find pairs of numbers that satisfy this condition. To start your list the first two pairs are: (house number, last number):
6 8 35 49
Input and Output
There is no input for this program. Output will consist of 10 lines each containing a pair of numbers, each printed right justified in a field of width 10 (as shown above).
PELL方程:http://hi.baidu.com/%C3%F9%D2%BB%D2%BB%D2%BB/blog/item/ec9dbcfc7ccf7f1fd8f9fd15.html
LANGUAGE:C
CODE:
#include<stdio.h>int main(){ int x=3,y=1,x_,y_,line=10,i; for(i=0;i<10;i++) { x_=3*x+8*y,y_=1*x+3*y; printf("%10d%10d\n",y_,(x_-1)/2); x=x_,y=y_; } return 0;}
- uva 138 - Street Numbers
- uva 138 street numbers
- UVA 138 Street Numbers
- UVA 138 Street Numbers
- UVA 138 Street Numbers
- UVa 138 - Street Numbers
- UVa 138 - Street Numbers
- UVa 138: Street Numbers
- UVA - 138 Street Numbers
- UVA 138 - Street Numbers
- UVa 138 Street Numbers
- uva 138 Street Numbers
- UVA - 138 Street Numbers
- UVA 138 Street Numbers
- UVa 138 - Street Numbers (门牌号)
- Street Numbers - UVa 138 水题
- UVa 138 Street Numbers(数论&Pell方程)
- uva 138 - Street Numbers(等差数列求和)
- 键盘驱动系列---JIURL键盘驱动 3
- 键盘驱动系列---JIURL键盘驱动 4
- Eclipse C C++ 中文语言包获取及安装MinGW
- 纪念开通博客
- c# 更改最大化按钮功能实现最大化时遮盖任务栏,点击Esc取消全屏
- UVA 138 Street Numbers
- 叶诗文得到了百万豪宅,价值三百多万
- HDU-1686(KMP)
- /usr/src/kernels/ 下没有当前内核文件夹 及 insmod错误Invalid module format
- 键盘驱动系列---JIURL键盘驱动 5
- ffmpeg开发指南
- 手机端和服务端交互
- 【ubuntu linux】 QT中使用MYSQL中文乱码解决方法
- Oracle BAM发送报警信息超长的解决方法