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. 编译 boost 库(win7+boost1.60+vs2008)

    参见:http://blog.csdn.net/u013074465/article/details/42532527 下载boost安装包 https://sourceforge.net/proje ...

  2. js的form表单提交url传参数(包含+等特殊字符)的解决方法

    方法一:(伪装form表单提交) linkredwin = function(A,B,C,D,E,F,G){        var formredwin = document.createElemen ...

  3. delphi7中添加QuickRep

    具体的方法是: delphi主菜单的Project|Options命令, 在Package选项卡的Desing packages列表中如果可以看到QuickReport Components选项, 那 ...

  4. 总结ASP.NET C#中经常用到的13个JS脚本代码

    1.按钮前后台事件 <asp:Button ID="Button1" runat="server" OnClick="Button1_Click ...

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

  6. 改善C#程序的建议5:引用类型赋值为null与加速垃圾回收

    http://www.cnblogs.com/luminji/archive/2011/04/07/2007205.html 在标准的Dispose模式中(见前一篇博客“C#中标准Dispose模式的 ...

  7. 批处理bat文件dos命令复制文件

    ::将“C:\Users\ZZ\Desktop\快捷处理\我我我哦我”路径下的文件复制到“C:\Temp\我我我哦我”路径下::/S表示“复制目录和子目录,除了空的.”::/E表示“复制目录和子目录, ...

  8. Nginx虚拟主机配置教程

    说明:配置之前先把域名解析到服务器IP地址上 站点1:bbs.osyunwei.com  程序所在目录/data/osyunwei/bbs 站点2:sns.osyunwei.com  程序所在目录/d ...

  9. vertical-align负值和margin-bottom负值的区别

    先看一下vertical-align在W3C当中的值有哪一些: 可是它有数值这一说确实很少提起,我们来看这么一段代码: <!DOCTYPE html> <html lang=&quo ...

  10. Android 使用GridView以表格的形式显示多张图片

    GridView用于在界面上按行.列分布的方式来显示多个组件(而ListView只是以按行的方式) 课程目标 学会使用GridView制作二维布局界面(行.列分布) 数据源(集合) --> 适配 ...