div

Codeforces Round #618 (Div. 2)

谁说胖子不能爱 提交于 2020-03-09 01:19:40
QAQ : 我太难了 A. Even But Not Even 题意: 给你一个长度为 n 的数组 a, 你可把其中一个数的值加一,这个操作你可以做无数次,要求最后的数组之和不等于零,数组之积不等于 0 ,输出所需最小的操作数。 思路: 暴力模拟即可,要求数组中不能有 0 ,和不等于 0 。 代码: #include <bits/stdc++.h> using namespace std; int num[105]; int main() { int T; scanf("%d",&T); while(T--) { int n; cin >> n; int sum = 0,ans = 0; for(int i = 0;i<n;++i) { cin >> num[i]; if(num[i]==0) { ans++; sum+=1; } else { sum+=num[i]; } } if(sum!=0) printf("%d\n",ans); else printf("%d\n",ans+1); } return 0; } B. Array Sharpening 题意: 给你一个数组 n,n 保证是个偶数,将这两个数组划分为等大小的两个数组,使这两个数组中位数之差的绝对值最小。输出这个最小值。 思路: 将数组从小到大排序,答案就是位于中间的两个数差的绝对值。 代码: #include

水平垂直居中div的3中方式

回眸只為那壹抹淺笑 提交于 2020-03-08 13:48:08
flex方式 <div class="dv"> <div class="dv2"></div> </div> .dv{ width: 400px; height: 400px; background-color: red; display: flex; justify-content: center; align-items: center; } .dv2{ width: 200px; height: 200px; background-color:blue; } position方式 <div class="dv3"> <div class="dv4"> </div> </div> <style> .dv3 { width: 400px; height: 400px; background-color: yellow; position: relative; } .dv4 { width: 200px; height: 200px; position: absolute; background-color: purple; margin: auto; top: 0; bottom: 0; left: 0; right: 0; } </style> position+transform 方式 <div class="dv5"> <div class="dv6"> </div> <

Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics)

岁酱吖の 提交于 2020-03-08 10:32:08
Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) A. Even Subset Sum Problem 题意 给出一串数,找到其中的一些数使得他们的和为偶数 题解 水题,找到一个偶数或者两个奇数就好了 代码 #include<iostream> #include<cstdio> #include<cstring> #define def 110 using namespace std; long a[def]; int main() { long _,ans0,ans1,ans2,n,i; for(scanf("%ld",&_);_;_--){ scanf("%ld",&n); ans0=ans1=ans2=-1; for(i=1;i<=n;i++){ scanf("%ld",&a[i]); if(a[i]%2==0) ans0=i; else if(ans1==-1) ans1=i; else ans2=i; } if(ans0==-1&&(ans1==-1||ans2==-1)) printf("-1\n"); else if(ans0!=-1) printf("1\n%ld\n",ans0); else printf("2\n%ld %ld\n",ans1,ans2); }

JavaScript指定打印 div 层

我只是一个虾纸丫 提交于 2020-03-08 09:31:34
function printdiv(printpage) { var headstr = "<html><head><title></title></head><body>"; var footstr = "</body>"; var newstr = document.all.item(printpage).innerHTML; var oldstr = document.body.innerHTML; document.body.innerHTML = headstr + newstr + footstr; window.print(); document.body.innerHTML = oldstr; return false; } //网页部分 <input name="b_print" type="button" class="ipt" onClick="printdiv('div_print');" value=" 打印测试 "> //打印的内容 <div id="div_print"> 要打印内容 </div> 来源: https://www.cnblogs.com/kevin1988/p/3745684.html

DIV未知高度的垂直居中代码

白昼怎懂夜的黑 提交于 2020-03-08 08:03:49
代码 <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html xmlns ="http://www.w3.org/1999/xhtml" > < head > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < title > Vertical centering in valid CSS </ title > < style type ="text/css" > body { padding : 0 ; margin : 0 ; font-size : 75% ; line-height : 140% ; font-family : Arial, Helvetica, sans-serif ; } body,html { height : 100% ; } a { color : #333 ; } a:hover { color : green ; } #outer { height : 100% ; overflow : hidden ; position : relative ; width :

div内容超过实现滚动条以及设置滚动条属性【CSS实现】

心不动则不痛 提交于 2020-03-07 22:56:15
例如,有一个id叫做mleft的div,当内容超过他原本的高度或者宽度,出现滚动条。 一般默认的滚动条太难看,此时我们要自定义样式 div的基本css: #mleft{ width:200px; height:500px; float:left; background-color:rgb(0,191,255); overflow:auto;/*当内容超过,出现滚动条*/ } 滚动条的css【以下对应的选择器都要有才行】 #mleft::-webkit-scrollbar{/*滚动条整体*/ width:10px; } #mleft::-webkit-scrollbar-track{/*滚动条轨道*/ background:#999; border-radius:2px; } #mleft::-webkit-scrollbar-thumb{/*滚动条里面的滑块*/ background:white; border-radius:10px; } #mleft::-webkit-scrollbar-thumb:hover{/*滚动条鼠标事件,鼠标放上去出现的事件*/ background:#333; } #mleft::-webkit-scrollbar-corner{/*滚动条边角*/ background:#179a16; } 注意:滚动条对应的所有选择器: ::-webkit

JS+CSS简单实现DIV遮罩层显示隐藏

孤者浪人 提交于 2020-03-06 21:48:56
1 <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > 2 < html xmlns ="http://www.w3.org/1999/xhtml" > 3 < head > 4 < title > DIV CSS遮罩层 </ title > 5 < script language ="javascript" type ="text/javascript" > 6 function showdiv() { 7 document.getElementById( " bg " ).style.display = " block " ; 8 document.getElementById( " show " ).style.display = " block " ; 9 } 10 function hidediv() { 11 document.getElementById( " bg " ).style.display = ' none ' ; 12 document.getElementById( " show " ).style.display = ' none ' ; 13 } 14 <

JS+CSS简单实现DIV遮罩层显示隐藏

孤街醉人 提交于 2020-03-06 21:43:41
1 <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > 2 < html xmlns ="http://www.w3.org/1999/xhtml" > 3 < head > 4 < title > DIV CSS遮罩层 </ title > 5 < script language ="javascript" type ="text/javascript" > 6 function showdiv() { 7 document.getElementById( " bg " ).style.display = " block " ; 8 document.getElementById( " show " ).style.display = " block " ; 9 } 10 function hidediv() { 11 document.getElementById( " bg " ).style.display = ' none ' ; 12 document.getElementById( " show " ).style.display = ' none ' ; 13 } 14 <

HTML5实现div拖拽

老子叫甜甜 提交于 2020-03-04 07:37:45
HTML5实现div拖拽 <!DOCTYPE html> < html lang = " en " > < head > < meta charset = " UTF-8 " > < meta name = " viewport " content = " width=device-width, initial-scale=1.0 " > < meta http-equiv = " X-UA-Compatible " content = " ie=edge " > < title > Document </ title > </ head > < body > < div style =" border : 1px solid red ; width : 500px ; height : 300px ; overflow : hidden ; margin : 20px " > < div id = " blackSquare " style =" position : relative ; width : 50px ; height : 50px ; background-color : black ; cursor : pointer ; color : #fff " > wjw </ div > </ div > </ body > < script > window .

2016.8.19 将div设置为隐藏使用style=“display:none”

我是研究僧i 提交于 2020-03-03 10:09:09
style="display:none"表示隐藏。 style="display:block"表示显示。 在代码中则使用$("#id").show(); 代码: 效果如图所示: 注意:display属性与visibiity属性的区别! visibility属性: 确定元素显示还是隐藏; visibility="visible|hidden",visible显示,hidden隐藏。 当visibility被设置为"hidden"的时候,元素虽然被隐藏了,但它仍然占据它原来所在的位置。 display属性: 就有一点不同了。visibility属性是隐藏元素但保持元素的浮动位置,而display实际上是设置元素的浮动特征。 其中 block和none值最常用。 block:默认值。 当display被设置为block(块)时,容器中所有的元素将会被当作一个单独的块,就像<DIV>元素一样,它会在那个点被放入到页面中。(实际上你可以设置<span>的display:block,使其可以像<DIV>一样工作。 inline: 将display设置为inline,将使其行为和元素inline一样---即使它是普通的块元素如<DIV>,它也将会被组合成像<span>那样的输出流。 none: 最后是display被设置:none,这时元素实际上就从页面中被移走