第一题:

按余数分类,1,2,3分别由哪些基数组成

1—>[1][2+3][3+3+3]

2—>[1+1][2][3+3]

3—>[1+1+1][1+2][3]

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const int maxn=2e5+20;
const ll MAX=0x7fffffffffffffff;
int main ()
{
ll n,a,b,c;
ll cost=MAX;
cin>>n>>a>>b>>c;
if(n%4==0)
cout<<"0"<<endl;
else
{
int tmp=4-n%4;
if(tmp==1)
{
cost=min(a,b+c);
cost=min(cost,c+c+c);
}
if(tmp==2)
{
cost=min(b,a+a);
cost=min(cost,c+c);
}
if(tmp==3)
{
cost=min(a+a+a,b+a);
cost=min(cost,c);
}
cout<<cost<<endl;
}
return 0;
}

第二题:

选出子序列和为正的项

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const int maxn=2e5+20;
const int MAX=0x7fffffff;
int a[102];
int b[102],c[102];
int main ()
{
int n,m,l,r,ans=0;
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>a[i];
int t=0;
while(m--)
{
cin>>l>>r;
int sum=0;
for(int i=l;i<=r;i++)
{
sum+=a[i];
}
if(sum>0)//子序列和为正
{
b[t]=l;
c[t]=r;
t++;
}
}
if(t==0)
{
cout<<'0';
return 0;
}
else
{
for(int i=1;i<=n;i++)
{
int num=0;
for(int j=0;j<t;j++)
{
if(i>=b[j]&&i<=c[j])num++;
}
ans+=num*a[i];
} }
cout<<ans<<endl;
return 0;
}

第三题:

构造法,寻找在一个区间未出现的最小整数。那么我们可以先求出   区间长度的最小值MIN

然后构造   0 1 2 3....MIN-1   0 1 2 .....这样构造的话 区间长度大于MIN的mex肯定不小于MIN

#include<stdio.h>
#include<algorithm>
#include<string.h>
typedef __int64 ll;
using namespace std;
int main()
{
int n,m,i,l,r,MIN=1000005;
int a[100005];
scanf("%d%d",&n,&m);
for(i=1;i<=m;i++)
{
scanf("%d%d",&l,&r);
MIN=min(r-l+1,MIN);
}
printf("%d\n",MIN);
for(i=1;i<=n;i++)
if(i!=n)
printf("%d ",i%MIN);
else
printf("%d\n",i%MIN);
return 0;
}

codeforces Round#381 div2的更多相关文章

  1. Codeforces Round #539 div2

    Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...

  2. 【前行】◇第3站◇ Codeforces Round #512 Div2

    [第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...

  3. Codeforces Round#320 Div2 解题报告

    Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...

  4. Codeforces Round #564(div2)

    Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...

  5. Codeforces Round #361 div2

    ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...

  6. Codeforces Round #626 Div2 D,E

    比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...

  7. CodeForces Round 192 Div2

    This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...

  8. Codeforces Round #381 (Div. 1) B. Alyona and a tree dfs序 二分 前缀和

    B. Alyona and a tree 题目连接: http://codeforces.com/contest/739/problem/B Description Alyona has a tree ...

  9. Codeforces Round #381 (Div. 1) A. Alyona and mex 构造

    A. Alyona and mex 题目连接: http://codeforces.com/contest/739/problem/A Description Alyona's mother want ...

随机推荐

  1. Alpha事后诸葛亮

    Aruba小组Cento项目Postmortem 队员: 408 409 410 428 429 431   设想和目标 1.我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰 ...

  2. TAC Alpha版本 冲冲冲!!!

    第1天 第2天 第3天 第4天 第5天 第6天 第7天 第8天 第9天 第10天 测试随笔 冲刺总结

  3. 怎样学习Java

    JAVA自学之路 一:学会选择 ,当你要走向社会的时候,就不要再把自己当成学生,不要把自己的将来交给别人,学会运用自己的眼睛去观察,去了解这个世界吧. 我讲一个通过招聘网站的观察方法: http:// ...

  4. 网络基础知识之 Ping

    ========================================假定主机A的IP地址是192.168.1.1,主机B的IP地址是192.168.1.2,都在同一子网内,则当你在主机A上 ...

  5. C#设置textBox只能输入数字(正数,负数,小数)简单实现

    /* *设置textBox只能输入数字(正数,负数,小数) */ public static bool NumberDotTextbox_KeyPress(object sender, KeyPres ...

  6. Shell文件权限和脚本执行

    一.预备知识 1.shell的作用   2.常识 (1)Tab键自动补全   使用Terminal时,输入命令的前几个字母,敲tab会自动补全命令或文件名.目录等. 好处:操作速度更快:不容易出错: ...

  7. SQL SERVER批量修改表名前缀

    比如前缀由mms_修改为 ets_ exec   sp_msforeachtable     @command1='  declare   @o   sysname,@n   sysname     ...

  8. MySql类似Oracle的dual虚拟表

    在mysql里也存在和oracle里类似的dual虚拟表:官方声明纯粹是为了满足select ... from...这一习惯问题,mysql会忽略对该表的引用. 你可千万注意了: select * f ...

  9. Excel—身份证生日提取

    一.只有18位的身份证号码 如: 身份证号 330682199302264000 41120019890823729X 231081199002256839 131101198203154666 36 ...

  10. 【总结1】PhpStorm配置XDebug(远程)调试PHP

    配置PhpStorm调试PHP 第一步:配置 XDebug 下载安装XDebug到本地环境,打开php.ini,参考配置如下: [XDebug] zend_extension = "D:\P ...