题意须要注意的一点就是,

序列是从外层最小的那个位置顺时针转一圈得来的。而且要求10在内圈

所以,这题暴力的话,假定最上面那个点一定是第一个点,算下和更新下即可。

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <set>
#include <vector>
#include <map>
#define MAXN 111
#define MAXM 55555
#define INF 1000000007
using namespace std;
int a[12];
int sum[6];
string ans, tmp;
int main()
{
int n = 10;
int first = 1;
ans = "", tmp = "";
for(int i = 1; i <= n; i++) a[i] = i;
do {
int pos = 1;
for(int i = 1; i <= 5; i++) {
if(a[i] < a[pos]) pos = i;
int z = i + 6;
if(z > 10) z = z - 5;
sum[i] = a[i] + a[i + 5] + a[z];
}
if(pos != 1) continue;
int flag = 1;
for(int i = 2; i <= 5; i++)
if(sum[i] != sum[i - 1]) flag = 0;
if(sum[1] != sum[5]) flag = 0;
for(int i = 6; i <= 10; i++) {
if(a[i] == 10) flag = 0;
}
tmp = "";
if(flag) {
for(int i = 1; i <= 5; i++) {
int z = i + 6;
if(z > 10) z = z - 5;
tmp += (a[i] + 'a');
tmp += (a[i + 5] + 'a');
tmp += (a[z] + 'a');
}
if(!first) {
if(ans < tmp) ans = tmp;
} else {
ans = tmp;
first = 1;
} }
}while(next_permutation(a + 1, a + n + 1));
for(int i = 0; i < 15; i++) printf("%d", ans[i] - 'a');
return 0;
}

Project Euler problem 68的更多相关文章

  1. Project Euler Problem 10

    Summation of primes Problem 10 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of ...

  2. Project Euler problem 62

    题目的大意很简单 做法的话. 我们就枚举1~10000的数的立方, 然后把这个立方中的有序重新排列,生成一个字符串s, 然后对于那些符合题目要求的肯定是生成同一个字符串的. 然后就可以用map来搞了 ...

  3. Project Euler problem 63

    这题略水啊 首先观察一下. 10 ^ x次方肯定是x + 1位的 所以底数肯定小于10的 那么我们就枚举1~9为底数 然后枚举幂级数就行了,直至不满足题目中的条件即可break cnt = 0 for ...

  4. Project Euler problem 61

    题意很明了. 然后我大概的做法就是暴搜了 先把每个几边形数中四位数的处理出来. 然后我就DFS回溯着找就行了. 比较简单吧. #include <cstdio> #include < ...

  5. Project Euler Problem 675

    ORZ foreverlasting聚聚,QQ上问了他好久才会了这题(所以我们又聊了好久的Gal) 我们先来尝试推导一下\(S\)的性质,我们利用狄利克雷卷积来推: \[2^\omega=I\ast| ...

  6. Project Euler Problem (1~10)

    1.If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. Th ...

  7. Project Euler Problem 26-Reciprocal cycles

    看样子,51nod 1035 最长的循环节 这道题应该是从pe搬过去的. 详解见论文的(二)那部分:http://web.math.sinica.edu.tw/math_media/d253/2531 ...

  8. Project Euler Problem 24-Lexicographic permutations

    全排列的生成,c++的next_permutation是O(n)生成全排列的.具体的O(n)生成全排列的算法,在 布鲁迪 的那本组合数学中有讲解(课本之外,我就看过这一本组合数学),冯速老师翻译的,具 ...

  9. Project Euler Problem 23-Non-abundant sums

    直接暴力搞就行,优化的地方应该还是计算因子和那里,优化方法在这里:http://www.cnblogs.com/guoyongheng/p/7780345.html 这题真坑,能被写成两个相同盈数之和 ...

随机推荐

  1. mysql.connector.errors.IntegrityError: 1048 (23000): Column 'request_url' cannot be null

    箭头指向的2的方向 少了一个request_url的值 调试: 直接 执行sql语句 是没问题的, 这样就知道问题是出在代码的逻辑 处理了: INSERT INTO response_time (nu ...

  2. 类方法__setattr__,__delattr__,__getattr__

    __getattr__,_delattr_,_getattr_ class Foo: x = 1 def __init__(self, y): self.y = y def __getattr__(s ...

  3. js进行的一些判断

    表达式 "^\\d+$" //非负整数(正整数 + 0) "^[0-9]*[1-9][0-9]*$" //正整数 "^((-\\d+)|(0+))$& ...

  4. hdfs深入:05、hdfs中的fsimage和edits的合并过程

    6.4.secondarynameNode如何辅助管理FSImage与Edits文件 ①:secnonaryNN通知NameNode切换editlog ②:secondaryNN从NameNode中获 ...

  5. 跨平台字符编码转换GBK、UTF8

    #if (defined _WIN32 || defined _WIN64) # include <windows.h> # include <stdio.h> # inclu ...

  6. SCOI2013 密码

    题目描述: Fish是一条生活在海里的鱼.有一天他很无聊,就到处去寻宝.他找到了位于海底深处的宫殿,但是一扇带有密码锁的大门却阻止了他的前进. 通过翻阅古籍,Fish 得知了这个密码的相关信息: 该密 ...

  7. Python 函数对象-函数嵌套-名称空间与作用域-闭包函数

    今日内容: 1. 函数对象 函数是第一类对象: 指的是函数名指向的值可以被当中数据去使用 1.可以被引用 2.可以当做参数传给另一个函数 3.可以当做一个函数的返回值 4.可以当做容器类型的元素 2. ...

  8. 零基础入门学习Python(9)--了不起的分支和循环3

    前言 本节继续介绍分支和循环 知识点 while循环 Python while循环与if条件分支有点类似,在条件为真的情况下,执行某一段指定的代码.不同的是只要条件为True,while循环就会一直重 ...

  9. win7系统上VMware虚拟机安装linux7.2上网配置

    环境: 本机是window7系统,安装VMware虚拟机,在VMware安装了Rdhat系统,想上网,在网上搜索了不少的配置方法,这篇文章介绍的比较全面,感谢分享,摘抄在这里让更多的爱好者学习.我自己 ...

  10. Python之“Hello World”

    Python之“Hello World” 了解Python: 编译型和解释型 编译:把明文代码执行前,先转换成二进制,在执行.这个过程叫编译 解释器:将明文代码转成二进制的 Linux中,gcc编译, ...