A---golden plate

http://codeforces.com/contest/1072/problem/A

题意:给一个n*m的格子,从最外层往里涂色,每次尽量涂最外面的那一圈,两圈涂色之间要间隔一格。问最多涂多少颜色。

思路:最外面一圈是2*n + 2(m - 2),然后行和列都减4就行了。里面的if都可以不用写,因为数据范围已经保证了

 #include <iostream>
#include <set>
#include <cmath>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long LL;
#define inf 0x7f7f7f7f int w, h, k; int main()
{
while(scanf("%d%d%d", &w, &h, &k) != EOF){ int ans = ;
for(int i = ; i < k; i++){
if(w <= || h <= )break;
if(h >= ){
ans += * w + * (h - );
}
else if(h >= ){
ans += w;
}
w -= ; h -= ; }
printf("%d\n", ans);
}
return ;
}

好的这是我这次比赛唯一过了的题目 吐血又猛的掉分了。

B---Curiosity Has No Limits

题意:给两个数量为n-1的数列a,b

a[i] = t[i] | t[i+1],  b[i] = t[i] & t[i+1],问是否可以找到这样的数列c

思路:因为a和b的数保证是在0~3.所以只有三种情况,对于所有的i,可以知道有可能的t[i]和t[i+1]

枚举最开始的数的两种可能,然后暴力跑一遍看看能不能符合。

一直WA在了第8组是因为,当a=3,b=0时,t可以是0/3, 也可以是1/2, 所以每当是这样的情况的时候要多考虑一下

 #include <iostream>
#include <set>
#include <cmath>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long LL;
#define inf 0x7f7f7f7f int n;
const int maxn = 1e5 + ;
int a[maxn], b[maxn], c[maxn]; int check()
{
for(int i = ; i <= n - ; i++){
if(a[i] == && b[i] != ){
return -;
}
else if(b[i] == && a[i] != ){
return -;
}
else if(b[i] == && a[i] == ){
return -;
}
else if(b[i] == && a[i] == ){
return -;
}
else{
int x, y, l, k;
if(b[i] == ){
x = ;
y = a[i];
if(a[i] == ){
l = ;
k = ;
}
}
else if(b[i] == ){
x = y = ;
}
else if(b[i] == ){
if(a[i] == ){
x = y = ;
}
else{
x = ;
y = ;
}
}
else if(b[i] == ){
if(a[i] == ){
x = y = ;
}
else{
x = ;
y = ;
}
}
if(c[i] == x){
c[i + ] = y;
}
else if(c[i] == y){
c[i + ] = x;
}
else if(b[i] == && a[i] == ){
if(c[i] == l){
c[i + ] = k;
}
else if(c[i] == k){
c[i + ] = l;
}
else return ;
}
else{
return ;
}
}
}
return ;
} int main()
{
while(scanf("%d", &n) != EOF){
for(int i = ; i <= n - ; i++){
scanf("%d", &a[i]);
}
for(int i = ; i <= n - ; i++){
scanf("%d", &b[i]);
} bool flag = true;
int tmp1, tmp2, tmp3, tmp4;
if(a[] == && b[] != ){
flag = false;
}
else if(b[] == && a[] != ){
flag = false;
}
else if(b[] == && a[] == ){
flag = false; }
else if(b[] == && a[] == ){
flag = false; }
else if(b[] == ){
tmp1 = ;
tmp2 = a[];
if(a[] == ){
tmp3 = ;
tmp4 = ;
}
}
else if(b[] == ){
tmp1 = tmp2 = ;
}
else if(b[] == ){
if(a[] == ){
tmp1 = tmp2 = ;
}
else{
tmp1 = ;
tmp2 = ;
}
}
else if(b[] == ){
if(a[] == ){
tmp1 = tmp2 = ;
}
else{
tmp1 = ;
tmp2 = ;
}
} if(!flag){
printf("NO\n");
continue;
}
/*if(n == 2){
printf("YES\n%d %d\n", tmp1, tmp2);
continue;
}*/
c[] = tmp1;
c[] = tmp2;
int f = check();
if(f == -){
printf("NO\n");
}
else if(f == ){
c[] = tmp2;
c[] = tmp1;
int x = check();
if(x == ){
printf("YES\n");
printf("%d", c[]);
for(int i = ; i <= n; i++){
printf(" %d", c[i]);
}
printf("\n");
}
else if(x == ){
if(b[] == && a[] == ){
c[] = tmp3;
c[] = tmp4;
int y = check();
if(y == ){
printf("YES\n");
printf("%d", c[]);
for(int i = ; i <= n; i++){
printf(" %d", c[i]);
}
printf("\n"); }
else if(y == ){
c[] = tmp4;
c[] = tmp3;
int z = check();
if(z == ){
printf("YES\n");
printf("%d", c[]);
for(int i = ; i <= n; i++){
printf(" %d", c[i]);
}
printf("\n"); }
else{
printf("NO\n");
}
}
}
else{
printf("NO\n");
}
}
}
else if(f == ){
printf("YES\n");
printf("%d", c[]);
for(int i = ; i <= n; i++){
printf(" %d", c[i]);
}
printf("\n");
}
}
return ;
}

C---Cram Time

题意:告诉你两天的时间长度a,b,学第i门课需要i个小时,并且不可以拆分到两天学。现在想要尽量多学习,问每天应该学习哪几门课。

思路:因为要尽量多的学,所以应该尽量选择前面的课程。我们先找出前x个之和小于等于a+b的最大的x,他就是总的学习科目数。

从大到小给第一天尽量去分配,当a学习第i个不够时,就跳过i给他挑一个小一些的刚好填进去的。

剩下的都是给b的。

注意要用longlong

 #include <iostream>
#include <set>
#include <cmath>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long LL;
#define inf 0x7f7f7f7f
#define lld I64d LL a, b;
const int maxn = 1e5 + ;
bool vis[maxn]; int main()
{
while(scanf("%lld%lld", &a, &b) != EOF){
memset(vis, , sizeof(vis));
LL ans = (sqrt( + * (a + b)) - ) / ;
//cout<<ans<<endl;
LL n = ;
for(LL i = ans; i >= ; i--){
if(a - i >= ){
vis[i] = true;
a -= i;
n++;
}
}
printf("%lld\n", n);
bool flag = false;
for(LL i = ans; i >= ; i--){ if(vis[i]){
if(flag){
printf(" ");
}
else{
flag = true;
}
printf("%lld", i);
}
}
printf("\n"); printf("%lld\n", ans - n);
flag = false;
for(LL i = ; i <= ans; i++){
if(!vis[i]){
if(flag){
printf(" ");
}
else{
flag = true;
}
printf("%lld", i);
}
}
printf("\n"); }
return ;
}

codeforces #516---ABC的更多相关文章

  1. [codeforces 516]A. Drazil and Factorial

    [codeforces 516]A. Drazil and Factorial 试题描述 Drazil is playing a math game with Varda. Let's define  ...

  2. codeforces#516 Div2---ABCD

    A---Make a triangle! http://codeforces.com/contest/1064/problem/A 题意: 给定三个整数表示三角形的边.每次给边长可以加一,问至少要加多 ...

  3. codeforces CF475 ABC 题解

    Bayan 2015 Contest Warm Up http://codeforces.com/contest/475 A - Bayan Bus B - Strongly Connected Ci ...

  4. Codeforces 802 ABC. Heidi and Library

    题目大意 你需要保证第\(i\)天时有第\(a_i\)种书.你可以在任何一天买书,买第\(i\)种书的代价为\(c_i\). 你最多同时拥有\(k\)本书,如果此时再买书,则必须先扔掉已拥有的一本书. ...

  5. Codeforces 1260 ABC

    DEF 题对于 wyh 来说过于毒瘤,十分不可做. A. Heating Description: 给定\(a,b\),将\(b\)分成至少\(a\)个正整数,使这些正整数的平方和最小. Soluti ...

  6. [CF787D]遗产(Legacy)-线段树-优化Dijkstra(内含数据生成器)

    Problem 遗产 题目大意 给出一个带权有向图,有三种操作: 1.u->v添加一条权值为w的边 2.区间[l,r]->v添加权值为w的边 3.v->区间[l,r]添加权值为w的边 ...

  7. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  8. Codeforces Round #516 (Div. 2)D. Labyrinth(BFS)

    题目链接:http://codeforces.com/contest/1064/problem/D 题目大意:给你一个n*m的图,图中包含两种符号,'.'表示可以行走,'*'表示障碍物不能行走,规定最 ...

  9. Codeforces Round #516 (Div. 2, by Moscow Team Olympiad) D. Labyrinth

    http://codeforces.com/contest/1064/problem/D 向上/向下加0,向左/右加1, step = 0,1,…… 求的是最少的步数,所以使用bfs. step=k ...

  10. Codeforces Round #516 (Div. 2) (A~E)

    目录 Codeforces 1064 A.Make a triangle! B.Equations of Mathematical Magic C.Oh Those Palindromes D.Lab ...

随机推荐

  1. ERROR 1045 (28000): Access denied for user 'root'@'127.0.0.1' (using password: YES)

    我的原因是在配置文件my.ini [mysqld]项,在其后加入了一句:skip-name-resolve 导致授权出现这个错误,把skip-name-resolve这项屏蔽了就好了. 场景2:对所有 ...

  2. yuv420图文详解

    YUV格式有两大类:planar和packed.对于planar的YUV格式,先连续存储所有像素点的Y,紧接着存储所有像素点的U,随后是所有像素点的V.对于packed的YUV格式,每个像素点的Y,U ...

  3. jquery -- 删除节点

    jQuery提供了三种删除节点的方法,即remove(),detach()和empty(). 测试所用HTML代码: <p title="选择你最喜欢的水果?">你最喜 ...

  4. par函数的adj 参数- 控制文字的对齐方式

    adj 用来控制文字的对齐方式,取值范围为0到1,控制图片中x轴和y轴标签,标题,以及通过text 添加的文字的对齐方式 0表示左对齐,代码示例: par(adj = 0)plot(1:5, 1:5, ...

  5. 使用GitHub和Eclipse进行javaEE开发步骤

    下载Git客户端:链接:http://pan.baidu.com/s/1jIueUEy 密码:7gef; 下载Eclipse javaee客户端:http://www.eclipse.org/down ...

  6. mongodb php auto increment 自增

    mongodb的自增实现根oracle,postgresql是差不多,都是通过计数器来实现的. oracle自增实现: 实例说明oracle序列用法 postgresql自增实现: postgresq ...

  7. 巧妙的利用Mongodb做地理空间查询

  8. oracle最精简客户端(3个文件+1个path变量就搞定oracle客户端)

    oracle最精简客户端: network\admin\tnsnames.ora (自己新建)oci.dlloraocieill.dll 将oci.dll的路径加到path变量中就可以了 tnsnam ...

  9. DoBox 下载

    DoBox下载 一款简单十分好用的办公助手,用于记录您接下来需要做的事情.待办事项小工具 - DoBox DoBox下载 下载地址:http://www.wxzzz.com/?id=141 最新版本: ...

  10. Java精选笔记_集合【Set(集合)接口】

    Set(集合)接口 简介 同样继承自Collection接口,它与Collection接口中的方法基本一致,并没有对Collection接口进行功能上的扩充,只是比Collection接口更加严格了. ...