round

Codeforces Round #433 Div. 2 B Maxim Buys an Apartment

大憨熊 提交于 2019-12-01 03:46:04
题意: 有n个屋子,其中k个屋子是有人住的,如果第i个屋子有人住,那么第i-1个屋子和第i+1个屋子就是特殊的,方便起见这里我们将特殊屋子的数量记为ans。然后给你n和k,让你输出最小的ans和最大的ans。 失误 总结:考虑不全面,没有逻辑关系 失误点:每个已经居住的房子要想周围是空的,达到最佳状态,则需要足够的地方,即3*k <= n,此时得到最大值2*k,否则得到 n-k,解题时要有足够的逻辑分析支撑 失误点2:此题数据范围1e9,看似不超int 2e10,但是实际运算过程中k*3则会超过int,所以要特别注意诸如此类的数据类型计算会爆int的情况,本场比赛c题也是这个问题 AC code: #include<cstdio> #include<algorithm> #include<cstring> #include<vector> #include<queue> #include<cmath> #include<iostream> using namespace std ; int main() { long long n,k; cin >>n>>k; if (k== 0 ) { printf ( "%d %d\n" ,k,k); } else if (k==n) { printf ( "0 0\n" ); } else { int u; if (k* 3 <=n) u =

【 Codeforces Round #596 [Div. 2] C p-binary】

◇◆丶佛笑我妖孽 提交于 2019-12-01 03:43:26
【 Codeforces Round #596 [Div. 2] C p-binary】 Description Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero). To combine their tastes, they invented p-binary numbers of the form 2x+p, where x is a non-negative integer. For example, some −9-binary (“minus nine” binary) numbers are: −8 (minus eight), 7 and 1015 (−8=20−9, 7=24−9, 1015=210−9). The boys now use p-binary numbers to represent everything. They now face a problem: given a positive integer n, what

自从来了阿里云做视频研发,我的生活发生了翻天覆地的变化

人走茶凉 提交于 2019-11-30 12:06:18
小A是一名普通程序员 去年10月 他经过重重面试 过五关斩六将 加入了阿里云视频云团队 然而他没想到的是 自从来了这 他的生活竟然发生了翻天覆地的变化 变化到底是什么? 今天我们一探究竟...... ROUND 1 刷某音 ROUND 2 追新番 ROUND 3 开电脑 ROUND 4 玩自拍 ROUND 5 看看书 ROUND 6 双十一 ROUND 7 玩游戏 ROUND 8 过马路 ROUND 9 吃火锅 ROUND 10 开火锅 ROUND 11 世界杯 ROUND 12 逛云栖 未完待续 ............ 自从来了阿里云做视频研发 大多程序员都和小A一样开始了 “不看足球看卡顿,不看猫晚看水位”的幸福生活 ............ 对他们来说 视频不止是娱乐和社交的载体 它象征着一种使命、一种责任 正是因为这群可爱程序员的 专注、热血和匠心 为全球300000+客户保驾护航 才能让用户们享受到 更加稳定、流畅、超清、极致的观看体验 ............ 对了 小A所在的视频云团队承包了 云栖大会「智能视频云」专场 就在9月27日13:30-16:30 地点:D1-402 欢迎来哦 阅读原文 本文为云栖社区原创内容,未经允许不得转载。 来源: https://my.oschina.net/u/1464083/blog/3110655

Codeforces Round #586 (Div. 1 + Div. 2)D(二分图构建,思维,结论需数论证明)

你说的曾经没有我的故事 提交于 2019-11-30 07:57:07
#include<bits/stdc++.h> using namespace std; long long a[200007]; vector<int>v[77]; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; for(int i=1;i<=n;++i){ cin>>a[i]; long long tmp=a[i]; int cnt=0; while(!(tmp&1)){ tmp/=2; ++cnt;//二进制上最后一位1的位置 } v[cnt].push_back(i); } int mx=v[0].size(); int pos=0; for(int i=1;i<=64;++i) if(v[i].size()>mx){ mx=v[i].size(); pos=i; } cout<<n-mx<<"\n"; for(int i=0;i<=64;++i){ if(i==pos) continue; for(int j=0;j<v[i].size();++j) cout<<a[v[i][j]]<<" "; } return 0; } 来源: https://www.cnblogs.com/ldudxy/p/11573814.html

神经网络3:多隐层感知器

爱⌒轻易说出口 提交于 2019-11-30 05:49:27
▶ 终于把之前的单隐层感知机改成了支持任意层数神经元的网络 ● 代码,参考【https://www.zybuluo.com/hanbingtao/note/476663】(原文错误太多,几乎是重写了)。采用了 class FullConnectedLayer 封装同一层的多个神经元,采用 class Network 封装所有神经元层,包含了相应的前向、后向等计算方法 1 import numpy as np 2 from functools import reduce 3 import matplotlib.pyplot as plt 4 import matplotlib.ticker as ticker 5 from mpl_toolkits.mplot3d import Axes3D 6 from mpl_toolkits.mplot3d.art3d import Poly3DCollection 7 from matplotlib.patches import Rectangle 8 from datetime import datetime as dt 9 10 global_dataSize = 1000 # 总数据大小 11 global_trainRatio = 0.3 # 训练集占比 12 global_ita = 0.4 # 学习率 13 global

ROUND 精度问题

独自空忆成欢 提交于 2019-11-29 18:30:48
MYSQL Round函 SELECT 25000000 , 25000000/100000000 -- 0.25 , ROUND(25000000/100000000,3) -- 0.25 , ROUND(25000000/10000000, 1) -- 2.5 , ROUND(0.25+1,1)-1 -- 0.3 , ROUND(1.25,1)-1 -- 0.3 , ROUND(0.26,1) -- 0.3 , ROUND(0.250006,0) -- 0 , ROUND(250006,1) -- 250006 ,ROUND(21.5,0) -- 22 ,ROUND(21.25,1) -- 21.3 数返回一个数值,该数值是按照指定的小数位数进行四舍五入运算的结果。可是当保留位跟着的即使是5,有可能进位,也有可能舍去,机会各50%。这样就会造成在应用程序中计算有误。下面这个函数能真正实现四舍五入功能,用以取代Round函数。 Public Function Round ToLarger(dblInputAsDouble,intDecimalsAsInteger) As Double   '执行Round()函数,有可能进位   '也有可能舍去 Dimstr Format String As String'格式化字符串’ 如果是“0”,则返回“0”,否则进行适当的格式化:  

python 向上取整ceil 向下取整floor 四舍五入round

时光毁灭记忆、已成空白 提交于 2019-11-29 12:32:49
1 #encoding:utf-8 2 import math 3 4 #向上取整 5 print "math.ceil---" 6 print "math.ceil(2.3) => ", math.ceil(2.3) 7 print "math.ceil(2.6) => ", math.ceil(2.6) 8 9 #向下取整 10 print "\nmath.floor---" 11 print "math.floor(2.3) => ", math.floor(2.3) 12 print "math.floor(2.6) => ", math.floor(2.6) 13 14 #四舍五入 15 print "\nround---" 16 print "round(2.3) => ", round(2.3) 17 print "round(2.6) => ", round(2.6) 18 19 #这三个的返回结果都是浮点型 20 print "\n\nNOTE:every result is type of float" 21 print "math.ceil(2) => ", math.ceil(2) 22 print "math.floor(2) => ", math.floor(2) 23 print "round(2) => ", round(2) 运行结果: 来源:

内置函数:数学计算,abs,divmod,round,pow,sum,min,max

时光毁灭记忆、已成空白 提交于 2019-11-28 10:48:23
ads:计算绝对值 l = [-1,5,-6,11,6,-19] print(sorted(l,key=abs))#按绝对值排序 for i in l: print(abs(i))#逐个打印绝对值 divmod:除几余几 print(divmod(10,3))#返回一个元组 round:小数精确,精确到小数点后几位,可以精确到小数点前几位,前几位用负数表示,均四舍五入 a = 8115/4 print(a.__round__(1))#变量a的内置方法 print(a.__round__(-2)) print(round(8115/4,1))#内置函数 print(round(8115/4,-2)) pow:幂运算 print(pow(2,3))#2的3次幂 sum:求和 ,传入一个可迭代对象求和,可以继续传入一个起始求和的参数,默认为0 l = [1,2,3,4,5,-5] print(sum(l))#10 print(sum(l,2))#12 min:返回给定参数的最大值,参数可以为序列。可以加入一个key的索引 l = [1,2,3,4,5,-5] print(min(l,key=abs))#绝对值最小 print(min(l))#最小 max:返回给定参数的最大值,参数可以为序列。可以加入一个key的索引 l = [1,2,3,4,5,-5] print(max(l,key

Codeforces Round #581 (Div. 2)A BowWow and the Timetable (思维)

寵の児 提交于 2019-11-28 01:52:14
A. BowWow and the Timetable time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output In the city of Saint Petersburg, a day lasts for 2100 minutes. From the main station of Saint Petersburg, a train departs after 1 minute, 4 minutes, 16 minutes, and so on; in other words, the train departs at time 4k for each integer k≥0. Team BowWow has arrived at the station at the time s and it is trying to count how many trains have they missed; in other words, the number of trains that have departed strictly before time s. For example if s=20, then they