Codeforces Round #194 (Div. 2) 部分题解
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) 部分题解的更多相关文章
- # Codeforces Round #529(Div.3)个人题解
Codeforces Round #529(Div.3)个人题解 前言: 闲来无事补了前天的cf,想着最近刷题有点点怠惰,就直接一场cf一场cf的刷算了,以后的题解也都会以每场的形式写出来 A. Re ...
- Codeforces Round #557 (Div. 1) 简要题解
Codeforces Round #557 (Div. 1) 简要题解 codeforces A. Hide and Seek 枚举起始位置\(a\),如果\(a\)未在序列中出现,则对答案有\(2\ ...
- Codeforces Round #540 (Div. 3) 部分题解
Codeforces Round #540 (Div. 3) 题目链接:https://codeforces.com/contest/1118 题目太多啦,解释题意都花很多时间...还有事情要做,就选 ...
- Codeforces Round #538 (Div. 2) (A-E题解)
Codeforces Round #538 (Div. 2) 题目链接:https://codeforces.com/contest/1114 A. Got Any Grapes? 题意: 有三个人, ...
- Codeforces Round #531 (Div. 3) ABCDEF题解
Codeforces Round #531 (Div. 3) 题目总链接:https://codeforces.com/contest/1102 A. Integer Sequence Dividin ...
- Codeforces Round #527 (Div. 3) ABCDEF题解
Codeforces Round #527 (Div. 3) 题解 题目总链接:https://codeforces.com/contest/1092 A. Uniform String 题意: 输入 ...
- Codeforces Round #499 (Div. 1)部分题解(B,C,D)
Codeforces Round #499 (Div. 1) 这场本来想和同学一起打\(\rm virtual\ contest\)的,结果有事耽搁了,之后又陆陆续续写了些,就综合起来发一篇题解. B ...
- Codeforces Round #545 (Div. 1) 简要题解
这里没有翻译 Codeforces Round #545 (Div. 1) T1 对于每行每列分别离散化,求出大于这个位置的数字的个数即可. # include <bits/stdc++.h&g ...
- Codeforces Round #624 (Div. 3)(题解)
Codeforces Round #624 (Div.3) 题目地址:https://codeforces.ml/contest/1311 B题:WeirdSort 题意:给出含有n个元素的数组a,和 ...
随机推荐
- Centos7.4 modsecurity with nginx 安装
1.准备: 系统环境:Centos7.4 软件及版本: nginx:OpenResty1.13.6.1 ModSecurity:ModSecurity v3.0.0rc1 (Linux) modsec ...
- 16.C语言可变参数
//可变参数实现多个参数求和 1 #define _CRT_SECURE_NO_WARNINGS #include <stdlib.h> #include <stdio.h> ...
- POJ 1191 记忆化搜索
(我是不会告诉你我是抄的http://www.cnblogs.com/scau20110726/archive/2013/02/27/2936050.html这个人的) 一开始没有想到要化一下方差的式 ...
- Reference Counting GC (Part two :Partial Mark & Sweep)
目录 部分标记清除算法 前提 dec_ref_cnt()函数 new_obj()函数 scan_hatch_queue()函数 paint_gray()函数 scan_gray()函数 collect ...
- 【Henu ACM Round#14 C】Duff and Weight Lifting
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 2^y可以由两个2^(y-1)相加得到. 则有一个贪心的策略. 就是2^x尽量都变成2^(x+1) (即能够凑就尽量凑) 如果x还有 ...
- CSUOJ 1549 Navigition Problem
1549: Navigition Problem Time Limit: 1 Sec Memory Limit: 256 MBSubmit: 65 Solved: 12 Description N ...
- UVA - 10032 Tug of War (二进制标记+01背包)
Description Problem F: Tug of War A tug of war is to be arranged at the local office picnic. For the ...
- 【LeetCode-面试算法经典-Java实现】【05-Longest Palindromic Substring(最大回文字符串)】
背景 近期開始研究算法,于是在leetcode上做算法题,第五题Longest Palindromic Substring便是关于回文子串的. 什么是回文字串 回文字符串是指将该字符串前后颠倒之后和该 ...
- nagios插件之登陆防火墙实现session监控
ssh_firewall_session.sh -- 登陆防火墙并运行dis session statistics firewall_check_sessions.c -- 调用上面脚本.过滤出ses ...
- Vue项目自动转换 px 为 rem,高保真还原设计图
技术栈 vue-cli:使用脚手架工具创建项目. postcss-pxtorem:转换px为rem的插件. 自动设置根节点html的font-size 因为rem单位是相对于根节点的字体大小的,所以通 ...