Python语言初学(为机器学习做准备) Avaricious Maryanna
来源:互联网 发布:k歌软件哪个好 编辑:程序博客网 时间:2024/06/06 03:56
Avaricious Maryanna Avaricious Maryanna
很巧的情况下学了python,今天上午刚看了两个小时python3,然后下午打比赛就用到了。因为py有个特点,整数可以无限大,不会出现相乘溢出的情况。
昨天去图书馆,结果工程书库没开门,在三楼南书库转了转,里面有很多外文书籍,很惊喜地发现了我想要的python学习书。而且是最新版的新书,全英的,wow。看了不到两章就在程序设计比赛中用到了。
python是动态语言,属于解释型的纯OO Language。
上面是两个链接,同一道题。题目来源 Google Cup.
下面py代码 及 题面。(代码中可能有些搞笑的写法,刚学。。。)
在终端中打表语句
for j in range(501): st = int(10 ** (j - 1)) ed = int(10 ** j) for i in range(st, ed): if i * i % ed == i: print(i)
解题代码
start = ([-1])start.append([-1, 0, 1, 5, 6])start.append([-1, 25, 76])start.append([-1, 376, 625])start.append([-1, 9376])start.append([-1, 90625])start.append([-1, 109376, 890625])for bit in range(7, 503):start.append([-1])ed = int(10 ** (bit - 1))mod = ed * 10for i in range(4, 0, -1):for st in start[bit - i]:if st == -1: continuefor it in range(0, 10):var = it * ed + stif var <= ed or var > mod: continueif var * var % mod == var :start[bit].append(var)start[bit].sort()T = int(input())kase = 0while T > 0:T -= 1n = int(input())kase += 1print("Case #%d: " % (kase), end = '')if len(start[n]) == 1:print("Impossible")else:for i in range(1, len(start[n]) - 1):print(start[n][i], end = ' ')print(start[n][-1])
AVARY - Avaricious Maryanna
After Maryanna found the treasure buried by 27 pilots in a secret cave, she wanted to leave there immediately. Unfortunately, finding the door closed because of the overweight treasure she carried, she had to find out the password of the lock. She remembered someone had told her the password is an N-digit natural decimal integer (without extra leading zeroes), and the N least significant digits of any positive integral power of that integer is same as itself. She, being a smart girl, came up with all the possible answers within 1 minute. After a few times of tries, she escaped from that cave successfully. To show your intelligence you may solve the same task with your computer within only 10 seconds!
Input
The first line contains T (T <= 1000), the number of test cases. T lines follow, each contains a single positive integer N(N<= 500).
Output
For each test case, output a single line, which should begin with the case number counting from 1, followed by all the possible passwords sorted in increasing order. If no such passwords exist, output Impossible instead. See the sample for more format details.
Example
Input:221Output:Case #1: 25 76Case #2: 0 1 5 6
- Python语言初学(为机器学习做准备) Avaricious Maryanna
- UVA 12009 - Avaricious Maryanna
- google杯邀请赛 Avaricious Maryanna
- UVA 12009 - Avaricious Maryanna(数论)
- uva 12009 - Avaricious Maryanna(暴力)
- 学习FFMPEG,为Encode Filter做准备
- 从高中英语为出国学习做准备
- Java基础(为学习java做准备)
- 机器学习之python开发环境准备
- 初学Python环境准备
- 2011ACM上海邀请赛A题(Avaricious Maryanna)----模拟+大数乘法
- 机器学习工程师面试前应该做的准备
- 为未来做准备
- 为实习做准备
- 为面试做准备!!
- 为WDF做准备
- 为2016做准备
- Python爬虫手机新浪主页,为登录做准备
- [BZOJ]2131 免费的馅饼 DP + 绝对值转化
- Django模型
- 判断两圆是否重合
- 分数线划定
- 蓝牙
- Python语言初学(为机器学习做准备) Avaricious Maryanna
- 网狐棋牌游戏平台服务器架构设计分析
- matplotlib 绘图可视化知识点整理
- centos编译时报错:error: bzlib.h: No such file or directory
- Ubantu系统安装搜狗输入法教程
- 五、ESP8266 之 UDP (基于LUA开发)
- MongoDB:1-MongoDB和Robomongo安装
- ZXing二维码扫描
- C++中虚析构函数的作用及其原理分析