A. Currency System in Geraldion:

  • 题意:有n中不同面额的纸币,问用这些纸币所不能加和到的值的最小值。
  • 思路:显然假设这些纸币的最小钱为1的话,它就能够组成随意面额。

    假设这些纸币的最小值大于1,那么它所不能组成的最小面额就是1.所以自学求最小值就可以。

  • 我的代码:
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LL;
const int M = 100009,INF = 0x3fffffff; int main(void) {
//problem: , address:
int n, x, y = INF;
cin >> n;
while (n--) {
cin >> x;
if (x < y) swap(x, y);
}
if(y <= 1) cout << "-1" << endl;
else cout << "1" << endl;
return 0;
}

B. Gerald is into Art:

  • 题意:给定三个矩形的 长和款。第一个矩形作为容器。最后两个矩形不可重叠且水平的放置在当中,问能否放下?
  • 思路:这里第一步先把第二个矩形放入容器的左下角显然是最好的策略,能够给第三个矩形最大的可能空间(比赛的时候不够细致,没有注意,第一个大矩形反正左下角必须满足能放下的条件,就没过大数据),注意这里第一个矩形有横放和竖放两种情况。第二步再把第三个矩形放入剩余空间,这时候放置有两种情况:,每种放置情况第三个矩形又分为横放和竖放两种类型。这样就把放置问题分为了8种情况,满足随意情况就可以。

  • 我的代码:
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LL;
const int M = 100009,INF = 0x3fffffff; int main(void) {
int a1, a2, a3, b1, b2, b3;
cin >> a1 >> b1 >> a2 >> b2 >> a3 >> b3;
int x = a1 - a2, y = b1 - b2;
bool ans = false;
if ( (b2 <= b1 && x >= a3 && b3 <= b1) || (x >= 0 && a3 <= a1 && b3 <= y) || (y >= 0 && x >= b3 && a3 <= b1) || (x >= 0 && b3 <= a1 && a3 <= y) ) ans =true;
x = a1 - b2;
y = b1 - a2;
if ( (y >= 0 && x >= a3 && b3 <= b1) || (x >= 0 && a3 <= a1 && b3 <= y) || (y >= 0 && x >= b3 && a3 <= b1) || (x >= 0 && b3 <= a1 && a3 <= y) ) ans =true;
if (ans) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}

C. Gerald’s Hexagon:

  • 题意:用等边三角形堆积成一个六边形,六边形每个内角的为120度。告诉你这个六边形的六条边的长度,问该六边形是由多少个等边三角形组成的。
  • 思路:求出这和整个六边形的面积。再除以三角形的面积,就能够了。

    依据内角都为120度的特点,总是能把六边形切为如图的四个三角形。边上三个三角形面积easy计算。那么依据余弦公式:

    c2=a2+b2−2abcosθ

    能够求出内部三角形的边长。

    再依据海伦公式:

    p=(a+b+c)/2
    s=p(p−a)(p−b)(p−c)−−−−−−−−−−−−−−−−−√

    就可以算出内部三角形面积。

  • 我的代码:
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LL;
const int M = 100009,INF = 0x3fffffff;
double pi = sqrt(3), eps = 1e-3; int main(void) {
double sum = 0, a, b, c, d, e, f;
cin >> a >> b >> c >> d >> e >> f;
double x = sqrt((a * a) + (b * b) + a * b);
double y = sqrt((c * c) + (d * d) + c * d);
double z = sqrt((e * e) + (f * f) + e * f);
double s = (x + y + z) / 2;
//cout << x << " " << y << " "<< z << endl;
sum += sqrt(s * (s - x) * (s - y) * (s - z));
//cout << sum << endl;
sum += 0.25 * pi * (a * b + c * d + e * f);
cout << int(sum / ( pi / 4) + eps) << endl;
return 0;
}

D. Equivalent Strings

  • 题意:给定两个字符串同性的法则。推断其是否同性。
  • 递归就可以。但是比赛的代码在大数据的时候超时了。后来加了一个剪枝过了。

    然后超时的主要原因是用了string后,会出现多次复制字符串的情况,把string换为char*,时间缩短10倍!

  • string实现的代码:
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LL;
const int M = 100009,INF = 0x3fffffff; bool same(string a, string b) {
int A[26], B[26];
memset(A, 0, sizeof(A));
memset(B, 0, sizeof(B));
for (int i = 0; i < a.size(); i++) {
A[a[i] - 'a']++;
B[b[i] - 'a']++;
}
for (int i = 0; i < 26; i++) {
if (A[i] != B[i]) return false;
}
if (a == b) return true;
if (a.size() % 2 != 0) return false;
string x1, x2, y1, y2;
for (int i = 0; i < a.size() / 2; i++) {
x1 += a[i];
x2 += b[i];
y1 += a[i + a.size() / 2];
y2 += b[i + a.size() / 2];
}
return (same(x1, x2) && same(y1, y2)) || (same(x1, y2) && same(y1, x2));
} int main(void) {
ios::sync_with_stdio(false);
string a, b;
while (cin >> a >> b) {
if (same(a, b)) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}
  • char* 实现的代码:
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LL;
const int M = 100009,INF = 0x3fffffff; bool str (char a[], char b[], int n) {
bool ans = true;
for (int i = 0; i < n; i++) {
if (a[i] != b[i]) {
ans = false;
break;
}
}
return !ans;
} bool same(char a[], char b[], int n) {
int A[26], B[26];
memset(A, 0, sizeof(A));
memset(B, 0, sizeof(B));
for (int i = 0; i < n; i++) {
A[a[i] - 'a']++;
B[b[i] - 'a']++;
}
for (int i = 0; i < 26; i++) if (A[i] != B[i]) return false;
if (!str(a, b, n)) return true;
if (n % 2 != 0) return false;
return (same(a, b + n / 2, n / 2) && same(a + n / 2, b, n / 2)) || (same(a, b, n / 2) && same(a + n / 2, b + n / 2, n / 2));
} int main(void) {
ios::sync_with_stdio(false);
char a[200009], b[200009];
while (cin >> a >> b) {
int n = strlen(a);
if (same(a, b, n)) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}

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

  1. Codeforces Round #324 (Div. 2)解题报告

    ---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“ ...

  2. Codeforces Round #382 (Div. 2) 解题报告

    CF一如既往在深夜举行,我也一如既往在周三上午的C++课上进行了virtual participation.这次div2的题目除了E题都水的一塌糊涂,参赛时的E题最后也没有几个参赛者AC,排名又成为了 ...

  3. Codeforces Round #380 (Div. 2) 解题报告

    第一次全程参加的CF比赛(虽然过了D题之后就开始干别的去了),人生第一次codeforces上分--(或许之前的比赛如果都参加全程也不会那么惨吧),终于回到了specialist的行列,感动~.虽然最 ...

  4. Codeforces Round #216 (Div. 2)解题报告

    又范低级错误! 只做了两题!一道还被HACK了,囧! A:看了很久!应该是到语文题: 代码:#include<iostream> #include<];    ,m2=;    ;i ...

  5. Codeforces Round #281 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/493 A题 写完后就交了,然后WA了,又读了一遍题,没找出错误后就开始搞B题了,后来回头重做的时候才发现,球员被红牌罚下场后还可 ...

  6. Codeforces Round #277 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/486 A题.Calculating Function 奇偶性判断,简单推导公式. #include<cstdio> ...

  7. Codeforces Round #276 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/485 A题.Factory 模拟.判断是否出现循环,如果出现,肯定不可能. 代码: #include<cstdio> ...

  8. Codeforces Round #350 (Div. 2)解题报告

    codeforces 670A. Holidays 题目链接: http://codeforces.com/contest/670/problem/A 题意: A. Holidays On the p ...

  9. Codeforces Round #479 (Div. 3)解题报告

    题目链接: http://codeforces.com/contest/977 A. Wrong Subtraction 题意 给定一个数x,求n次操作输出.操作规则:10的倍数则除10,否则减1 直 ...

随机推荐

  1. ZBrush功能特性之变形

    使用ZBrush内置的变形功能可以让用户对三维网格轻松应用扭曲.拉伸.弯曲及其他各种变化.在ZBrush当中,有超过20种的强大变形类型,可以应用于任何轴向.用户只需单击几次即可创造出高级形状,如图所 ...

  2. PHP SOAP模块的使用方法:NON-WSDL模式

    PHP SOAP扩展可以帮助我们很轻松的实现web service服务,在PHP的SOAP扩展中主要有两种操作模式:WSDL模式和NON-WSDL模式,前者通过使用WSDL文件名作为参数,并从 WSD ...

  3. UVA-12083 Guardian of Decency 二分图 最大独立集

    题目链接:https://cn.vjudge.net/problem/UVA-12083 题意 学校组织去郊游,选择最多人数,使得任意两个人之间不能谈恋爱 不恋爱条件是高差大于40.同性.喜欢的音乐风 ...

  4. linux 连接 NAS

    [root@kvm-server ~]# mount -o username=user01,password=1234567890 //192.168.31.20/share /mnt/nas Cou ...

  5. suse 11 sp4 bond 网卡 mode0模式

    开启网卡: ifocnfig eth1 up 点亮网卡ethtool eth1 db2:~ # cat /etc/sysconfig/network/ifcfg-bond0 DEVICE='bond0 ...

  6. HTTP——学习笔记(5)

    我们通信的过程中会有哪些风险?: 1.HTTP不会对通信方的身份进行确认 因为HTTP协议中的请求和相应不会对通信方进行确认,就是不管发送或接收信息的人是不是之前的人,都不妨碍信息的发送或接收. 缺点 ...

  7. Qt之OpenSSL

    简述 OpenSSL是一个强大的安全套接字层密码库,囊括主要的密码算法.常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用. 简述 下载安装 使用 更多参考 下载安装 ...

  8. ES聚合底层机制-bucket深的话采用广度优先更好,而如果是年度统计还是深度优先好

    见原文,仅仅摘录部分:https://www.elastic.co/guide/cn/elasticsearch/guide/current/_preventing_combinatorial_exp ...

  9. sklearn 词袋 CountVectorizer

    from sklearn.feature_extraction.text import CountVectorizer texts=["dog cat fish","do ...

  10. 1.C语言指针学习之外挂篇

    学习了c语言的指针,那么指针能做什么呢,首先,他可以写外挂 首先我们来编写一个dll,挂载到植物大战僵尸上,记住是dll,因为如果你创建一个应用程序,该应用程序是不能操作其他程序的地址的. 第一步,打 ...