(Problem 62)Cubic permutations(待续)
The cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 (4053). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits which are also cube.
Find the smallest cube for which exactly five permutations of its digits are cube.
题目大意:
立方数 41063625 (3453) 通过排列可以得到两个另外的立方数: 56623104 (3843) 和 66430125 (4053)。 实际上41063625是最小的三个(不多不少)排列是立方数的立方数。
找出最小的立方数,其五个(不多不少)排列是立方数。
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h> #define N 8000 typedef struct data {
long long n;
char na[];
}; struct data a[N]; int cmp1(const void * a, const void * b)
{
struct data * c = (struct data * )a;
struct data * d = (struct data * )b;
return strcmp(c ->na, d ->na);
} int cmp2(const void * a, const void * b)
{
return *(char *)a - *(char *)b;
} void solve()
{
int i, j;
long long t, min;
min = ;
for(i = , j = ; i < N; i++, j++) {
a[i].n = j * j * j;
sprintf(a[i].na, "%lld", a[i].n);
qsort(a[i].na, strlen(a[i].na), sizeof(char), cmp2);
}
qsort(a, N, sizeof(a[]), cmp1); for(int i = ; i < N; i++) {
if(strcmp(a[i].na, a[i + ].na) == && strcmp(a[i].na, a[i + ].na) == &&
strcmp(a[i].na, a[i + ].na) == && strcmp(a[i].na, a[i + ].na) == ) {
printf("%lld\n%lld\n%lld\n%lld\n%lld\n", a[i].n, a[i + ].n, a[i + ].n, a[i + ].n, a[i + ].n); }
}
//printf("%lld\n", min);
} int main()
{
solve();
return ;
}
(Problem 62)Cubic permutations(待续)的更多相关文章
- Project Euler 62: Cubic permutations
立方数\(41063625 (345^3)\)的各位数重新排列形成另外两个立方数\(6623104 (384^3)\)和\(66430125 (405^3)\).事实上,\(41063625\)是满足 ...
- 欧拉工程第62题:Cubic permutations
题目链接 找出最小的立方数,它的各位数的排列能够形成五个立方数 解决关键点: 这五个数的由相同的数组成的 可以用HashMap,Key是由各位数字形成的key,value记录由这几个数组成的立方数出现 ...
- Project Euler problem 62
题目的大意很简单 做法的话. 我们就枚举1~10000的数的立方, 然后把这个立方中的有序重新排列,生成一个字符串s, 然后对于那些符合题目要求的肯定是生成同一个字符串的. 然后就可以用map来搞了 ...
- POJ2369 Permutations(置换的周期)
链接:http://poj.org/problem?id=2369 Permutations Time Limit: 1000MS Memory Limit: 65536K Total Submi ...
- [CC150] Get all permutations of a string
Problem: Compute all permutations of a string of unique characters. 此题用循环的方式不好做,下面是一种递归的思路: 把给的字符串看成 ...
- oj 1031 random permutation
Problem A: Random Permutations Time Limit: 1 Sec Memory Limit: 128 MB Submit: 91 Solved: 54 Descri ...
- List of NP-complete problems
This is a list of some of the more commonly known problems that are NP-complete when expressed as de ...
- 2009-2010 ACM-ICPC, NEERC, Western Subregional Contest
2009-2010 ACM-ICPC, NEERC, Western Subregional Contest 排名 A B C D E F G H I J K L X 1 0 1 1 1 0 1 X ...
- AtCoder Grand Contest 038 简要题解
从这里开始 比赛目录 Problem A 01 Matrix Code #include <bits/stdc++.h> using namespace std; typedef bool ...
随机推荐
- SQL学习之空值(Null)检索
在创建表表,我们可以指定其中的列包不包含值,在一列不包含值时,我们可以称其包含空值null. 确定值是否为null,不能简单的检查是否=null.select语句有一个特殊的where子句,可用来检查 ...
- Deep Learning(深度学习)学习笔记整理系列之(二)
Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...
- 选择器,$("A+B") 和$("A~B") 的理解
在我发表这个理解之前,我有看过博客园 永恒浪子 大神的 JQuery选择器大全(http://www.cnblogs.com/hulang/archive/2011/01/12/1933771.htm ...
- c# Linq及Lamda表达式应用经验之 GroupBy 分组
示例1: GroupBy 分组在List<>泛型中的应用 原表: 按姓名Nam 分组后结果: 对DATATABLE 进行LAMDA查询时必须在项目的引用中添加 System.Data.Da ...
- leetcode Reverse Integer python
class Solution(object): def reverse(self, x): """ :type x: int :rtype: int "&quo ...
- Hadoop 处理“Name node is in safe mode”问题(转)
运行hadoop程序时,有时候会报以下错误:org.apache.hadoop.dfs.SafeModeException: Cannot delete /user/hadoop/input. Nam ...
- 页面打开直接执行a点击事件
<script> window.onload = function(){ function autoclick(){ var url = document.getElementById(' ...
- POJ 1823 Hotel 线段树
题目链接 线段树的区间合并. 和上一题差不多....第三种操作只需要输出maxx[1]的值就可以. #include <iostream> #include <vector> ...
- The method of using code coverage tool
Please look at the following blog: http://blog.csdn.net/superqa/article/details/9060521 Use ReportG ...
- BOOL、sizeof
BOOL使用前需要声明 #include <stdbool.h>(这个头文件定义了bool,true,false等宏) int a[5]; sizeof(a[5]),sizeof是关键字, ...