A.

解一个方程。

还是厚颜无耻地暴力吧~

#include <iostream>
using namespace std; int r1, r2, c1, c2, d1, d2;
bool chk(int x1, int x2, int x3, int x4)
{
int ok = 1;
if(x1 == x2 || x1 == x3 || x1 == x4 || x2 == x3 || x2==x4 || x3==x4) ok = 0;
if(x1 + x2 != r1) ok = 0;
if(x3 + x4 != r2) ok = 0;
if(x1 + x3 != c1) ok = 0;
if(x2 + x4 != c2) ok = 0;
if(x1 + x4 != d1) ok = 0;
if(x2 + x3 != d2) ok = 0;
return ok;
} int main()
{
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for(int x1=1;x1<=9;x1++)for(int x2=1;x2<=9;x2++)
for(int x3=1;x3<=9;x3++)for(int x4=1;x4<=9;x4++) {
if(chk(x1, x2, x3, x4)) {
cout << x1 << " " << x2 << endl;
cout << x3 << " " << x4 << endl;
return 0;
}
}
cout << -1 << endl;
}

B.

可以练一练码力的题。

#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
char s[202];int minu = 0, n, dot;
vector<char> v;
void rush() {
if(s[1] == '-') minu = 1;
else return; for(int i=1;i<=n-1;i++) {
s[i] = s[i+1];
}
n --; dot --;
}
int main()
{
scanf("%s", s+1);
n = strlen(s+1);
dot = n+1;
for(int i=1;i<=n;i++)
{
if(s[i] == '.') dot = i;
}
rush();
v.push_back(s[1]);
for(int i=2;i<=min(n, dot+2);i++) {
if((dot - i) % 3 == 0 && dot != i) {
v.push_back(',');
}
v.push_back(s[i]);
}
if(dot == n-1) v.push_back('0');
if(dot == n+1) v.push_back('.'), v.push_back('0'), v.push_back('0');
if(minu) printf("(");
printf("$");
for(int i=0;i<v.size();i++) {
printf("%c", v[i]);
}
if(minu) printf(")");
}

C. 给出X,求Y-X的最大值与最小值。

X = A * B * C [A,B,C皆为正整数]

Y = (A+1) * (B+2) * (C+2) [取名为①式]

题解:

我们可以用sqrt(X)的复杂度枚举A。

展开吧!①式!

然后就会发现。B, C越接近,Y越小。【根据基本不等式得到的】

然后开始枚举B的值。【枚举姿势:从sqrt(X/A)向1枚举B】

#include <cmath>
#include <iostream>
using namespace std;
typedef long long LL;
LL n, minc = 1e15, maxc = -1e15;
void solve(LL a) {
LL t = n / a;
maxc = max(maxc, (a+1)*(t+2)*(LL)3 - n);
LL tmp = (LL)sqrt(t) + 1;
for(LL b = tmp; b >= 1; b--) {
if(t % b == 0) {
minc = min(minc, (a+1)*(b+2)*(t/b+2) - n);
}
} }
int main()
{
cin >> n;
for(LL a = 1; a * a <= n; a ++) {
if(n % a == 0) {
solve(a);
solve(n/a);
}
}
cout << minc << " " << maxc << endl;
}

  

D.

很有趣的一题!

给一个n * m的棋盘。往上放棋子。

然后往上放棋子。如果一个骑士可以从A跳到B。那么A和B不能同时放棋子。

问最多可以放几个棋子。

思路:

先将棋盘按照国际象棋棋盘的方式染色。【就是黑白交错的那种啦!】

然后发现骑士从黑格子只能跳到白格子。从白格子只能跳到黑格子。

所以我们可以在所有黑格子上放棋子。于是可以放$\frac{(mn+1)}{2}$个棋子

不妨设m <= n

当m=1时,$ans = n$

当m=2时,

ans = n+1 (n为奇数)

ans = n+2 (n%4=2)

构造方法如下:

AABBAABBAA

AABBAABBAA

A表示放置棋子。B表示不放棋子

#include <iostream>
using namespace std;
int n, m; int main()
{
cin >> n >> m;
int ans = (m*n+1)/2;
if(n > m) swap(n, m);
if(n == 1) ans = m;
if(n == 2) {
if(m % 2 == 1) ans = m+1;
if(m % 4 == 2) ans = m+2;
}
cout << ans << endl;
}

  

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

  1. Codeforces Round #182 (Div. 1)题解【ABCD】

    Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...

  2. Codeforces Round #608 (Div. 2) 题解

    目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...

  3. Codeforces Round #525 (Div. 2)题解

    Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...

  4. Codeforces Round #528 (Div. 2)题解

    Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...

  5. Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F

    Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...

  6. Codeforces Round #677 (Div. 3) 题解

    Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...

  7. Codeforces Round #665 (Div. 2) 题解

    Codeforces Round #665 (Div. 2) 题解 写得有点晚了,估计都官方题解看完切掉了,没人看我的了qaq. 目录 Codeforces Round #665 (Div. 2) 题 ...

  8. Codeforces Round #160 (Div. 1) 题解【ABCD】

    Codeforces Round #160 (Div. 1) A - Maxim and Discounts 题意 给你n个折扣,m个物品,每个折扣都可以使用无限次,每次你使用第i个折扣的时候,你必须 ...

  9. Codeforces Round #383 (Div. 2) 题解【ABCDE】

    Codeforces Round #383 (Div. 2) A. Arpa's hard exam and Mehrdad's naive cheat 题意 求1378^n mod 10 题解 直接 ...

随机推荐

  1. Android 瘦身之道 ---- so文件

    Android 瘦身之道 ---- so文件 [TOC] 1. 前言 目前Android 瘦身只有几个方面可以入手,因为apk的结构就已经固定了. res 目录下的资源文件.(通常是压缩图片,比如 矢 ...

  2. AOP学习笔记一

    软件开发的目的是为了解决各种需求,包括业务需求和系统需求.目前,业界通过使用面向对象的编程思想,已经可以对业务需求等普通关注点进行很好的抽象与封装,并且使之模块化.但是对于系统需求一类的关注点来说,情 ...

  3. javaScript 基础学习笔记

    边看视频和书记得有点杂. 1.插入JS标签 一种是在文档中插入<script></script>标签.另一种是把javaScript代码放在.js文件中.放在head中如. & ...

  4. 分离你的spring配置文件,让结构更清晰

    前言 接着上一篇的,这次框架的改变也成功分离了spring的配置文件. 以前,spring的配置文件从一开始的一点,到后面的逐渐变多,慢慢的,在一个spring的配置文件中就包含了好几块不同的bean ...

  5. xshell配色Solarized Dark

    转自:xshell配色Solarized Dark [Solarized_Dark] text(bold)= magenta(bold)=6c71c4 text= white(bold)=fdf6e3 ...

  6. Android Weekly Notes Issue #253

    Android Weekly Issue #253 April 16th, 2017 Android Weely Issue #253. 本期内容包括: Android O新推出的自定义字体支持; 用 ...

  7. 光场相机重聚焦之二——Lytro Illum记录光场

    上一节中大概讲述了光场相机和光场的参数化表示,这一节就说一下光场相机内部是如何记录光场以及实现重聚焦的. 博主用的是Lytro Illum,所以就以Illum为例来说了,Illum的功能还是挺多的,上 ...

  8. 【从无到有】HTML的初识——part1

    Ⅰ.HTML的初识 1.HTML:超文本标签语言(网页源代码) 2.html的基本结构: <html> <head> <meta charset="utf-8& ...

  9. 各种API总结大全 JAVA、HTML、HTML5等等

    本文章,发现新的API会进行更新,如果你们觉得有新的版本或者拥有新的,也可以发有邮箱到"zenglei8732@163.com"当中,本人会在12小时内更新,非常感谢!!! HTM ...

  10. python3.x元组打印错误 TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'

    原创by南山南北秋悲 欢迎引用!请注明原地址:http://www.cnblogs.com/hwd9654/p/5676746.html  谢谢! TypeError: unsupported ope ...