Codeforces Round #196 (Div. 2) 少部分题解
A:sort以后求差值最小
int a[];
int main()
{
int n,m;
cin>>n>>m;
for(int i = ; i < m ; i++) cin>>a[i];
sort(a,a+m);
int mm = INF;
for(int i = ; i+n- < m ; i++)
mm = min(mm,a[i+n-]-a[i]);
cout<<mm<<endl;
return ;
}
B:求屏幕黑框占屏幕的几分之几 . 求LCM后的差值
LL gcd(LL a,LL b){ return b?gcd(b,a%b):a; }
LL lcm(LL a,LL b){ return a*b/gcd(a,b); }
int main()
{
LL a,b,c,d;
LL a1,b1,c1,d1;
cin>>a>>b>>c>>d;
a1 = a;
b1 = b;
c1 = c;
d1 = d;
LL p = lcm(a,c);
b = b * (p/a);
a = p;
d = d * (p/c);
c = p;
if(b > d) {
LL x = b-d;
LL y = b;
printf("%I64d/%I64d\n",x/gcd(x,y),y/gcd(x,y));
return ;
}else if(b == d) printf("0/1\n");
LL q = lcm(b1,d1);
a1 = a1 * (q/b1);
b1 = q;
c1 = c1 * (q/d1);
d1 = q;
if(a1 > c1){
LL x = a1-c1;
LL y = a1;
printf("%I64d/%I64d\n",x/gcd(x,y),y/gcd(x,y));
return ;
}
return ;
}
Codeforces Round #196 (Div. 2) 少部分题解的更多相关文章
- Codeforces Round #195 (Div. 2) 少部分题解
太困了于是没做...第二天看题蘑菇题居多就只切了简单的两个... A:直接输出... int main() { //FIN; //FOUT; int x,y; cin>>x>> ...
- Codeforces Round #612 (Div. 2) 前四题题解
这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...
- Codeforces Round #198 (Div. 2)A,B题解
Codeforces Round #198 (Div. 2) 昨天看到奋斗群的群赛,好奇的去做了一下, 大概花了3个小时Ak,我大概可以退役了吧 那下面来稍微总结一下 A. The Wall Iahu ...
- Codeforces Round #672 (Div. 2) A - C1题解
[Codeforces Round #672 (Div. 2) A - C1 ] 题目链接# A. Cubes Sorting 思路: " If Wheatley needs more th ...
- Codeforces Round #196 (Div. 1) 题解
(CF唯一不好的地方就是时差……不过还好没去考,考的话就等着滚回Div. 2了……) A - Quiz 裸的贪心,不过要用矩阵乘法优化或者直接推通式然后快速幂.不过本傻叉做的时候脑子一片混乱,导致WA ...
- Codeforces Round #196 (Div. 2) D. Book of Evil 树形dp
题目链接: http://codeforces.com/problemset/problem/337/D D. Book of Evil time limit per test2 secondsmem ...
- Codeforces Round #614 (Div. 2) A-E简要题解
链接:https://codeforces.com/contest/1293 A. ConneR and the A.R.C. Markland-N 题意:略 思路:上下枚举1000次扫一遍,比较一下 ...
- Codeforces Round #610 (Div. 2) A-E简要题解
contest链接: https://codeforces.com/contest/1282 A. Temporarily unavailable 题意: 给一个区间L,R通有网络,有个点x,在x+r ...
- Codeforces Round #611 (Div. 3) A-F简要题解
contest链接:https://codeforces.com/contest/1283 A. Minutes Before the New Year 题意:给一个当前时间,输出离第二天差多少分钟 ...
随机推荐
- vue 中使用querySelect 封装的万能选择器
function query (el) { if (typeof el === 'string') { var selector = el; el = document.querySelector(e ...
- nginx旧版本升级新版本
比如我们现在所用的是 nginx 是1.4 版本,过了一段时间后我们有新的稳定版 1.6 问世,我们想升级到新的版本怎么办? 1.把新版本解压.安装,然后将 sbin/ng ...
- [洛谷P1726][codevs1332]上白泽慧音
题目大意:求一个有向图的最大强连通分量中点的个数,并输出这些点(字典序最小). 解题思路:裸的强连通分量. 数据小,求完强连通分量后排序+vector大小比较即可(vector有小于运算符). C++ ...
- [HNOI2004]高精度开根
题目:洛谷P2293.BZOJ1213. 题目大意:给你$n,k(n\leq 10^{10000},k\leq 50)$,求$\lfloor \sqrt[k]{n}\rfloor$. 解题思路:高精度 ...
- C语言操作数截断
//测试截断 #include <stdio.h> int main() { int a = 0x80000001; unsigned int b = 0x80000001; printf ...
- 【SRM 717 div2 A】 NiceTable
Problem Statement You are given a vector t that describes a rectangular table of zeroes and ones. Ea ...
- C# Winform利用POST传值方式模拟表单提交数据(Winform与网页交互)
其原理是,利用winfrom模拟表单提交数据.将要提交的參数提交给网页,网页运行代码.得到数据.然后Winform程序将网页的全部源码读取下来.这样就达到windows应用程序和web应用程序之间传參 ...
- 【LeetCode-面试算法经典-Java实现】【063-Unique Paths II(唯一路径问题II)】
[063-Unique Paths II(唯一路径问题II)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Follow up for "Unique Pa ...
- html5的代码验证
http://html5.validator.nu/ http://validator.w3.org/#validate_by_uri
- SQL Source Control
https://documentation.red-gate.com/display/SOC5/SQL+Source+Control+5+documentation Working with migr ...