python 取整itertools
#coding:utf-8
import sys
import itertools def MaxString(n,nums): list1 = nums
list2 = []
for i in range(1, len(list1) + 1):
iter = itertools.combinations(list1, i)
m=list(iter)
k=len(m)
for j in range(k):
if sum(m[j])%n==0:
list2.append(m[j])
print(list2)
k=len(list2[len(list2)-1])
if k!=0:
print(k)
else:
print(0)
if __name__=='__main__':
a=int(input())
b=[int(i) for i in sys.stdin.readline().split(' ')]
MaxString(a,b)
python 取整itertools的更多相关文章
- Python取整及保留小数小结
1.int() 向下取整 内置函数 n = 3.75 print(int(n))>>> 3 n = 3.25 print(int(n))>>> 3 2.round ...
- python 取整的两种方法
问题简介: 要把一个浮点数(float)整数部分提取出来.比如把“2.1”变成“2”的这一过程:现在我们给这个过程起一个名字叫“取整”.那么它 在python中大致可以有两种写法 写法1)类型转换: ...
- python 取整
1.向下取整 向下取整直接用内建的 int() 函数即可: >>> a = 3.75 >>> int(a) 3 2.四舍五入 对数字进行四舍五入用 round() ...
- Python 向上取整的算法
一.初衷: 有时候我们分页展示数据的时候,需要计算页数.一般都是向上取整,例如counts=205 pageCouts=20 ,pages= 11 页. 一般的除法只是取整数部分,达不到要求. 二.方 ...
- python 精确计算与向上取整 decimal math.ceil
1. 精确计算 python的float型不精确,需要导入decimal包,以下是不精确举例: 导入decimal包后: 2. 向上取整 一般的取整数(向下取整): 向上取整的方法:
- #python计算结果百位500向下取整,(0-499取000,500-999取500)
!/usr/bin/env python coding:utf-8 计算结果百位500向下取整,(0-499取000,500-999取500) import math calc_Amount = fl ...
- python中的数字取整(ceil,floor,round)概念和用法
python中的数学运算函数(ceil,floor,round)的主要任务是截掉小数以后的位数.总体来说 就是取整用的.只是三者之间有微妙的区别: floor() :把数字变小 ceil() : ...
- 使用python爬取整本《盗墓笔记》
一.前言 <盗墓笔记>是一本经典的盗墓题材小说,故事情节引人入胜.本文将使用python2.7通过小说网站http://www.daomubiji.com/来爬取整本盗墓笔记并保存,在这一 ...
- Why Python's Integer Division Floors ---- python int(6/-132)时答案不一致,向下取整
leetcode150题中有一个步骤: int(6/-132) == 0 or ==-1? 在自己本地python3环境跑是int(6/-132) =0,但是提交的时候确实-1. 查找相关资料解惑: ...
随机推荐
- Qt 信号槽
Qt4与Qt5的信号槽有些不同: 1. Qt4的槽函数必须使用slots关键字声明,而Qt5中已经不再需要了,槽函数可以是任何能和信号关联的成员函数. 2. Qt4指定信号函数和槽函数需用SIGNAL ...
- this指针的调整
我们先来看一段代码: #include <iostream> using namespace std; class A { public: int a; A( ) { printf(&qu ...
- git创建仓库,并提交代码(第一次创建并提交)(转)
一直想学GIT,一直不曾学会.主要是GUI界面的很少,命令行大多记不住.今天尝试提交代码,按GIT上给的方法,没料到既然提交成功了. 于是把它记下来,方便以后学习. 代码是学习用的,没多大意义: 下图 ...
- Nginx打开目录浏览功能(autoindex)以及常见问题解决方案
Nginx默认是不允许列出整个目录的.如需此功能,打开nginx.conf文件,在location server 或 http段中加入autoindex on;另外两个参数最好也加上去: autoin ...
- Cache Lucene IndexReader with Apache Commons Pool
IndexReaderFactory.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 2 ...
- 自己整理lnmp安装
1. 操作系统 CentOS release 6.5(final) 2. 安装mysql # yum install mysql-server #vi /etc/my.cnf +def ...
- 使用web页面实现oracle的安装和测试
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- My97DatePicker 日历控件
My97DatePicker 是一款非常强大的日历控件,使用也非常简单,也能修改源码,牛逼我就不吹了,自己用用看 使用 1.引入 <script language="javascrip ...
- [leetcode]174. Dungeon Game地牢游戏
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...
- Loitor_产品(二)校准立体摄像机
[1]Loitor VI Sensor 可以通过 ROS 自自带的双目相机标定工工具 cameracalibrator.py 来标定相机内参,详细过程http://wiki.ros.org/camer ...