[6 kyu] Playing with digits
[6 kyu] Playing with digits
文章目录
- [6 kyu] Playing with digits
- Question
- Sample Tests
- My Answer (accepted)
- Suggested Answer
Question
Sample Tests
My Answer (accepted)
import math
def dig_pow(n, p):ans = 0for item in list(str(n)):ans += math.pow(int(item), p)p += 1if ans%n == 0:return int(ans/n)return -1
Suggested Answer
def dig_pow(n, p):s = 0for i,c in enumerate(str(n)):s += pow(int(c),p+i)return s/n if s%n==0 else -1
[6 kyu] Playing with digits相关推荐
- Go语言基础(codewars---6kyu和5kyu)
文章目录 说明 一.String相关题 1.Stop gninnipS My sdroW!(6kyu) 2.Consecutive strings(6kyu) 3.Build Tower(6kyu) ...
- 小恐龙游戏python_补一波之前说好的用DQN自动玩Chrome浏览器的小恐龙游戏呗~
原文链接补一波之前说好的用DQN自动玩Chrome浏览器的小恐龙游戏呗~mp.weixin.qq.com 效果展示 在cmd窗口运行如下命令即可: 模型训练: python TRexRush.py ...
- UVa Problem 10067 Playing With Wheels (摆弄轮子)
// Playing With Wheels (摆弄轮子) // PC/UVa IDs: 110902/10067, Popularity: C, Success rate: average Leve ...
- Android Edittext digits 属性限制输入的内容
digits属性中设置允许的字符,未允许的字符即使软键盘上有显示,点击后也无法显示到EditText中. 例如显示显示输入的内容为数字字母以及,和. 就可以使用如下 <EditTextandro ...
- python字符串常量_python教程---字符串常量ascii_letters、punctuation、digits、whitespace等...
字符串常量 此模块中定义的常量为: string.ascii_letters 下文所述 ascii_lowercase 和 ascii_uppercase 常量的拼连. 该值不依赖于语言区域. str ...
- UVA 1482 - Playing With Stones(SG打表规律)
UVA 1482 - Playing With Stones 题目链接 题意:给定n堆石头,每次选一堆取至少一个.不超过一半的石子,最后不能取的输,问是否先手必胜 思路:数值非常大.无法直接递推sg函 ...
- [LeetCode] Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...
- Playing Video on iPhone Cocos2D-X
原文地址:http:///www.cocos2d-x.org/boards/7/topics/550 Got this working, thought I'd share: Can also be ...
- Leetcode刷题记录[python]——258 Add Digits
一.前言 做这题有个小收获,关于Digital root的解法,有个极方便的小公式: 二.题258 Add Digits Given a non-negative integer num, repea ...
最新文章
- linux 误删除mysql表能恢复吗_Linux下Oracle误删除数据文件恢复操作
- 用Leangoo敏捷开发工具如何管理用户故事?
- Python中读取、显示和保存图片的方法
- Linux 普通进程 后台进程 守护进程(转)
- 全国计算机等级考试题库二级C操作题100套(第09套)
- Python趣味编程---Python也会讲笑话
- LeetCode MySQL 1607. 没有卖出的卖家
- C#LeetCode刷题之#283-移动零(Move Zeroes)
- linux元组和列表的区别,列表,元组,集合
- UDP套接字编程以及提高UDP可靠性的方法
- 为什么有 HTTPS?因为 HTTP 不安全!
- 执行update操作的话,就会报“Connection is read-only. Queries leading to data modification are not allowed”的异常。
- java无法加载主类_java运行显示“找不到或无法加载主类”!
- 9.2NOIP模拟题
- Java基础语法——Java语言介绍
- JAVA并发编程实践-中文-高清-带书签-完整版
- 基于Linux的小项目-在线词典
- wireshark抓包并复原图像
- 手机禁止安装app,刷机才能恢复
- java web课程设计之图书管理系统