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

序列是从外层最小的那个位置顺时针转一圈得来的。而且要求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. ar - 建立, 修改档案或从档案中抽取成员.

    总览 ar [-]{dmpqrtx}[abcfilNoPsSuvV] [membername] [count] archive files... 描述 GNU 组织的ar 程序 用于建立, 修改档案 ...

  2. CAD参数绘制批注(com接口)

    C#中实现代码说明: private void DrawComment() { MxDrawComment com = new MxDrawComment(); MxDrawPoint pt = ne ...

  3. JavaSE-22 反射

    学习要点 反射概念 反射的应用 反射概述 1  反射机制 定义 Java反射机制是指在程序在运行状态中,动态获取信息以及动态调用对象方法的功能. Java反射的动态性质:运行时生成对象实例.运行期间调 ...

  4. (3)Gojs model简介

    (3)Gojs model简介 在GoJS中,model用来存储表的基本数据,包括node.link等具体对象和属性,与其在视觉上的展示效果不相关.model中往往只保存相对简单的数据,最方便且持久化 ...

  5. BZOJ 2502 Luogu P4843 清理雪道 最小流

    题意: 滑雪场坐落在FJ省西北部的若干座山上. 从空中鸟瞰,滑雪场可以看作一个有向无环图,每条弧代表一个斜坡(即雪道),弧的方向代表斜坡下降的方向. 你的团队负责每周定时清理雪道.你们拥有一架直升飞机 ...

  6. Python re模块 subprocess模块

    re模块 内部实现不是Python 而是调用了c的库 re是什么 正则 表达 式子 就是一些带有特殊含义的符号或者符号的组合作用: 对字符串进行过滤 在一对字符串中找到所关心的内容 你就需要告诉计算机 ...

  7. win7 x64安装glpk

    下载glpk,下载地址:http://ftp.gnu.org/gnu/glpk/

  8. MySQL-----唯一索引

    唯一索引: 单列唯一索引和联合唯一索引 索引是为了加速查找. 唯一索引是加了约束条件.例如主外键. 唯一索引的约束: 约束不能重复(可以为空) 主键不能重复(不能为空) 加速查找 create tab ...

  9. YOLOv3配置(win10+opencv3.40+cuda9.1+cudnn7.1+vs2015)

    最近心血来潮想学一下YOLOv3,于是就去网上看了YOLOv3在win10下的配置教程.在配置过程中塌坑无数,花了很多时间和精力,所以我想就此写一篇博客来介绍在在win10+vs2015的环境下如何配 ...

  10. Springboot 缓存使用

    . CachingProvider . CacheManager . Cache . Entry . Expiry 1. 开启基于注解的缓存 @EnableCaching 下面列出几个核心的注解 @C ...