http://codeforces.com/contest/334

A题意:1-n^2 平均分成 n 份,每份n个数,且和相同

解法 : 构造矩阵1-n^2的矩阵即可

int a[][];
int main()
{
int n;
scanf("%d",&n);
int k = n*n;
int c = ;
for(int i = ; i < n ; i++)
for(int j = ; j < n ; j++)
a[i][j] = c++;}
for(int i = ; i < n ; i++)
{
for(int j = ; j < n ; j++)
printf("%d ",a[j][(i+j)%n]);
puts("");
}
return ;
}

B:8个点能否关于矩形对称

解法: 直接暴力判断8个点,注意判重

struct point
{
int x,y;
}p[];
int cmp(point a,point b){
if(a.x == b.x) return a.y<b.y;
return a.x < b.x;
}
int main()
{
for(int i = ; i < ; i++)
cin>>p[i].x>>p[i].y;
sort(p,p+,cmp);
for(int i = ; i < ; i++)
for(int j = ; j < ; j++)
if(i != j && p[i].x == p[j].x && p[i].y == p[j].y)
{
cout<<"ugly"<<endl;
return ;
}
if(p[].x == p[].x && p[].x == p[].x && p[].x == p[].x
&& p[].x == p[].x && p[].x == p[].x)
{
if(p[].y == p[].y && p[].y == p[].y && p[].y == p[].y
&& p[].y == p[].y && p[].y == p[].y)
cout<<"respectable"<<endl;
else cout<<"ugly"<<endl;
}else cout<<"ugly"<<endl;
return ;
}

C题意: 用面值为3的次幂的硬币 购买价值为n的商品 , 要求硬币总价值>n且硬币数最多且这些硬币的子集不能>=n

解法 : 贪心,如果非3的倍数一定是n/3+1 即全换成3

否则就不能换成3要换成面值更大的 以此类推直到不为3^k为止

int main() {
LL n;
cin>>n;
while(n % == ) n /= ;
cout<<(n/)+<<endl;
}

D题意: 在n*n矩阵中 有一些不能走的格子, 从边界(非顶角)出发 能直线走到对面边界的最多方案数

解法 : 如果中间没有不能走的格子 ,对于在(x,x)上相交的十字形一共有2种不冲突的放法

可以证出: 其中一定存在一种对其他情况不影响走法 ----------------------------------画图可归纳

奇数情况特判中间点即可

bool bx[],by[];
int n,m;
int main()
{
//freopen("in.txt","r",stdin);
cin>>n>>m;
while(m--)
{
int x,y;
cin>>x>>y;
bx[x] = ;
by[y] = ;
}
int res = ;
for(int i = ; i < n ; i++)
{
if(bx[i] == ) res++;
if(by[i] == ) res++;
}
if(n% == && bx[n/+] == && by[n/+] == ) res--;
cout<<res<<endl;
return ;
}

Codeforces Round #194 (Div. 2) 部分题解的更多相关文章

  1. # Codeforces Round #529(Div.3)个人题解

    Codeforces Round #529(Div.3)个人题解 前言: 闲来无事补了前天的cf,想着最近刷题有点点怠惰,就直接一场cf一场cf的刷算了,以后的题解也都会以每场的形式写出来 A. Re ...

  2. Codeforces Round #557 (Div. 1) 简要题解

    Codeforces Round #557 (Div. 1) 简要题解 codeforces A. Hide and Seek 枚举起始位置\(a\),如果\(a\)未在序列中出现,则对答案有\(2\ ...

  3. Codeforces Round #540 (Div. 3) 部分题解

    Codeforces Round #540 (Div. 3) 题目链接:https://codeforces.com/contest/1118 题目太多啦,解释题意都花很多时间...还有事情要做,就选 ...

  4. Codeforces Round #538 (Div. 2) (A-E题解)

    Codeforces Round #538 (Div. 2) 题目链接:https://codeforces.com/contest/1114 A. Got Any Grapes? 题意: 有三个人, ...

  5. Codeforces Round #531 (Div. 3) ABCDEF题解

    Codeforces Round #531 (Div. 3) 题目总链接:https://codeforces.com/contest/1102 A. Integer Sequence Dividin ...

  6. Codeforces Round #527 (Div. 3) ABCDEF题解

    Codeforces Round #527 (Div. 3) 题解 题目总链接:https://codeforces.com/contest/1092 A. Uniform String 题意: 输入 ...

  7. Codeforces Round #499 (Div. 1)部分题解(B,C,D)

    Codeforces Round #499 (Div. 1) 这场本来想和同学一起打\(\rm virtual\ contest\)的,结果有事耽搁了,之后又陆陆续续写了些,就综合起来发一篇题解. B ...

  8. Codeforces Round #545 (Div. 1) 简要题解

    这里没有翻译 Codeforces Round #545 (Div. 1) T1 对于每行每列分别离散化,求出大于这个位置的数字的个数即可. # include <bits/stdc++.h&g ...

  9. Codeforces Round #624 (Div. 3)(题解)

    Codeforces Round #624 (Div.3) 题目地址:https://codeforces.ml/contest/1311 B题:WeirdSort 题意:给出含有n个元素的数组a,和 ...

随机推荐

  1. Equals和==比較

    总结一下: 对于字符串来说.两个比較的都是对象的值,而且是等效的,这是由于MS重写了==运算符和Equals方法所致             对于非字符串的其它引用类型(非匿名类型)两个比較的都是对象 ...

  2. Bloxorz I (poj 3322 水bfs)

    Language: Default Bloxorz I Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5443   Acce ...

  3. orm 通用方法——RunProc调用存储过程

    该方法暂不支持带返回值的存储过程,期待能人补充指点. 定义代码: /** * 描述:执行存储过程 * 作者:Tianqi * 日期:2014-09-16 * param:rs orm.RawSeter ...

  4. 解决Esxi5下安装Windows 8的问题

    在VM8工作站版下安装windows 8没有问题,可是到了Esxi5下,非得安装补丁不可.补丁下载地址: http://kb.vmware.com/selfservice/microsites/sea ...

  5. Linux常用系统管理软件

    1.BleachBit是一款开源的系统清理工具,它可以释放磁盘空间,保护您的隐私,清除缓存,删除cookies.internet历史.临时文件.日志和丢弃的垃圾文件等,支持清除应用的残留数据,切碎文件 ...

  6. Python——Pygame实现生命游戏(game of life)

    模块:pygame import pygame,sys,time,random from pygame.locals import * """Color"&qu ...

  7. JS实现分页效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. CSUOJ 1651 Weirdo

    1651: Weirdo Time Limit: 5 Sec  Memory Limit: 128 MBSubmit: 40  Solved: 21[Submit][Status][Web Board ...

  9. 淘宝在hbase中的应用和优化

    本文来自于NoSQLFan联合作者@koven2049,他在淘宝从事Hadoop及HBase相关的应用和优化. 对Hadoop.HBase都有深入的了解,本文就是其在工作中对HBase的应用优化小结, ...

  10. es6 -- 透彻掌握Promise的使用,读这篇就够了

    Promise的重要性我认为我没有必要多讲,概括起来说就是必须得掌握,而且还要掌握透彻.这篇文章的开头,主要跟大家分析一下,为什么会有Promise出现. 在实际的使用当中,有非常多的应用场景我们不能 ...