codeforce Round #643 #645 #646 div2

Round #643

problem A

#include<bits/stdc++.h>
using namespace std;
#define ll long long ll findmin(ll x){
ll minn=99;
while(x!=0){
if(x%10<minn)
minn=x%10;
x/=10;
}
return minn;
} ll findmax(ll x){
ll maxx=-1;
while(x!=0){
if(x%10>maxx)
maxx=x%10;
x/=10;
}
return maxx;
} int main(){
int n;scanf("%d",&n);
ll a,k;
while(n--){
scanf("%lld %lld",&a,&k);
for(ll i=1;i<=k-1;++i){
if(findmin(a)==0)break;
a+=findmin(a)*findmax(a);
}
printf("%lld\n",a);
a=0;
}
return 0;
}

problem B

#include<bits/stdc++.h>
using namespace std;
#define N 300005
int a[N];
int n,m,sum=0,k=1,tmp; int main(){
scanf("%d",&n);
while(n--){
scanf("%d",&m);
for(int i=0;i<m;++i){
scanf("%d",&a[i]);
}
sort(a,a+m);
tmp=a[0];
for(int i=1;i<=m;++i){
if(tmp<=k){
sum++;k=1;
tmp=a[i];
}
else{
tmp=a[i];
k++;
}
}
cout<<sum<<endl;
k=1;tmp=0;sum=0;
}
return 0;
}

Round #645

problem A

#include<bits/stdc++.h>
using namespace std; int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int k;cin>>k;
int n,m;
while(k--){
cin>>n>>m;
if(n*m%2==1)
cout<<(n*m+1)/2<<endl;
else
cout<<n*m/2<<endl;
}
return 0;
}
}

problem B

#include<bits/stdc++.h>
using namespace std;
int a[200005]; int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int k;cin>>k;
int n;
int flag=0;
while(k--){
cin>>n;
for(int i=1;i<=n;++i){
cin>>a[i];
}
sort(a+1,a+n+1);
for(int i=1;i<=n;++i){
if(a[i]<=i)flag=i;
}
cout<<flag+1<<endl;
flag=0; }
return 0;
}

problem C

#include<bits/stdc++.h>
using namespace std; int main(){
ios::sync_with_stdio(false);
cin.tie(0);
long long x,y,x1,y1,t;cin>>t;
while(t--){
cin>>x>>y>>x1>>y1;
cout<<(x1-x)*(y1-y)+1<<endl;
}
return 0;
}

Round #646

problem A

#include <bits/stdc++.h>
using namespace std; int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t, n, x, k;
cin >> t;
int sum = 0;
while (t--)
{
cin >> n >> x;
for (int i = 0; i < n; ++i)
{
cin >> k;
if (k % 2 == 1)
{
sum++;
}
}
if ((x == n && sum % 2 == 0) || (sum == 0) || (x % 2 == 0 && sum == n))
cout << "No" << endl;
else
cout << "Yes" << endl;
}
sum = 0;
return 0;
}

problem B

#include <bits/stdc++.h>
using namespace std; int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
string x;
int cnt0 = 0, cnt1 = 0;
int ans = 9999;
int tmp = 0;
while (t--)
{
cin >> x;
if (x.size() <= 2)
cout << "0" << endl;
else if (x.size() == 3)
{
if (x == "101" || x == "010")
cout << "1" << endl;
else
cout << "0" << endl;
}
else
{
for (int i = 0; i < x.size(); ++i)
{
if (x[i] == '0')
cnt0++;
else
cnt1++;
}
ans = min(cnt0, cnt1);
tmp = cnt0;
for (int i = 0; i < x.size(); ++i)
{ //ans01
if (x[i] == '1')
tmp++;
else
tmp--;
if (tmp < ans)
ans = tmp;
}
tmp = cnt1;
for (int i = 0; i < x.size(); ++i)
{ //ans10
if (x[i] == '0')
tmp++;
else
tmp--;
if (tmp < ans)
ans = tmp;
}
cout << ans << endl;
ans = 9999;
cnt0 = 0;
cnt1 = 0;
}
}
return 0;
}

Codeforce Round #643 #645 #646 (Div2)的更多相关文章

  1. Codeforce Round #216 Div2

    e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头 ...

  2. Codeforce Round #211 Div2

    真的是b到不行啊! 尼玛C题一个这么简单的题目没出 aabbccddee 正确的是aabccdee 我的是   aabcdee 硬是TM的不够用,想半天还以为自己的是对的... A:题... B:题. ...

  3. Codeforce Round #228 Div2

    这次的A题没注意要到100- -, B题没做,后来做要注意下1和long long C题当时坑的一B,用了个蠢办法,后来还错了,现在改了,还是蠢办法,等等再去用dp吧,而且本来就只有01用个鸡巴的树状 ...

  4. Codeforce Round #227 Div2

    这回的看错时间了! 发现理论可以涨分的- -

  5. Codeforce Round #226 Div2

    这次CF虽然,但是- - 第一题看了很久的题目意思额,虽然慢了点- -,但还算没出错,还学会了hack了- -,还+了100- - 第二题想了很久- -...后来发现可以暴力- -,哎 第三题本来也应 ...

  6. Codeforce Round #225 Div2

    这回的C- -,弄逆序,我以为要弄个正的和反的,没想到是等价的,弄两个还是正确的,结果我又没注意1和0只能指1个方向,结果弄了4个,取了4个的最小值就错了,自己作死没弄出来...,后面又玩去了...哎 ...

  7. Codeforce Round #224 Div2

    一下子没打,这比赛,就被虐成狗!

  8. Codeforce Round #222 Div2

    这场断网,本来有个别人的比较卡的无线 但后面睡着了- -! C:额,逆向想下! B:... A:...

  9. Codeforce Round #221 Div2

    每次的CF都是一把辛酸泪! 什么时候能打破这局面,昨天做着睡着了! 有时候有的题目也就差一线! 哎,! A:杠杆原理! B:算最后负的和! B:没弄出来当时就脑短路... C:事后写了个n*log(n ...

随机推荐

  1. poj2762 判断一个图中任意两点是否存在可达路径 也可看成DAG的最小覆盖点是否为1

      Going from u to v or from v to u? Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 179 ...

  2. 程序员都在用的 IDEA 插件(不断更新)

    IDEA一些不错的插件分享 目录 IDEA一些不错的插件分享 插件集合 CamelCase Translation LiveEdit MarkDown Navigator Jrebel CheckSt ...

  3. 一文带你学会基于SpringAop实现操作日志的记录

    前言 大家好,这里是经典鸡翅,今天给大家带来一篇基于SpringAop实现的操作日志记录的解决的方案.大家可能会说,切,操作日志记录这么简单的东西,老生常谈了.不! 网上的操作日志一般就是记录操作人, ...

  4. [Unity2d系列教程] 006.Unity如何根据图片自动生成Animator

    Unity制作2D产品的时候,我们在制作动画的时候,要不断的生成Animation,Animator等等资源,如果动画一多的话,就变得麻烦.由于Unity是支持插件开发的,我们可以添加一个Editor ...

  5. SET运算符

    -- SET操作符: -- union   联合去重 两个表的字段个数和类型都得一样,起别名 应该在第一个表上操作,,排序按照第一列从小到大来排的 select employee_id, depart ...

  6. 深入理解JVM(③)——之HotSpot虚拟机对象探秘

    前言 上篇文章介绍了Java虚拟机的运行时数据区域,大致明白了Java虚拟机内存模型的概况,下面就基于实用优先的原则,以最常用的虚拟机HotSpot和最常用的内存区域Java堆为例,升入探讨一下Hot ...

  7. CSS选择器有哪些?哪些属性可以继承?

    CSS选择符: id选择器(#myid). 类选择器(.myclassname). 标签选择器(div, h1, p). 相邻选择器(h1 + p). 子选择器(ul > li). 后代选择器( ...

  8. Java实现 LeetCode 753 破解保险箱(递归)

    753. 破解保险箱 有一个需要密码才能打开的保险箱.密码是 n 位数, 密码的每一位是 k 位序列 0, 1, -, k-1 中的一个 . 你可以随意输入密码,保险箱会自动记住最后 n 位输入,如果 ...

  9. Java实现 蓝桥杯 算法提高 拿糖果

    算法提高 拿糖果 时间限制:1.0s 内存限制:256.0MB 问题描述 妈妈给小B买了N块糖!但是她不允许小B直接吃掉. 假设当前有M块糖,小B每次可以拿P块糖,其中P是M的一个不大于根号下M的质因 ...

  10. Java实现 LeetCode 322 零钱兑换

    322. 零钱兑换 给定不同面额的硬币 coins 和一个总金额 amount.编写一个函数来计算可以凑成总金额所需的最少的硬币个数.如果没有任何一种硬币组合能组成总金额,返回 -1. 示例 1: 输 ...