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(待续)的更多相关文章

  1. Project Euler 62: Cubic permutations

    立方数\(41063625 (345^3)\)的各位数重新排列形成另外两个立方数\(6623104 (384^3)\)和\(66430125 (405^3)\).事实上,\(41063625\)是满足 ...

  2. 欧拉工程第62题:Cubic permutations

    题目链接 找出最小的立方数,它的各位数的排列能够形成五个立方数 解决关键点: 这五个数的由相同的数组成的 可以用HashMap,Key是由各位数字形成的key,value记录由这几个数组成的立方数出现 ...

  3. Project Euler problem 62

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

  4. POJ2369 Permutations(置换的周期)

    链接:http://poj.org/problem?id=2369 Permutations Time Limit: 1000MS   Memory Limit: 65536K Total Submi ...

  5. [CC150] Get all permutations of a string

    Problem: Compute all permutations of a string of unique characters. 此题用循环的方式不好做,下面是一种递归的思路: 把给的字符串看成 ...

  6. oj 1031 random permutation

    Problem A: Random Permutations Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 91  Solved: 54 Descri ...

  7. 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 ...

  8. 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 ...

  9. AtCoder Grand Contest 038 简要题解

    从这里开始 比赛目录 Problem A 01 Matrix Code #include <bits/stdc++.h> using namespace std; typedef bool ...

随机推荐

  1. Android 开发佳站3

    eclipse 某些java文件乱码 摘要: [一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/archive/2013/04/24/3040219.h ...

  2. 编写可维护的JS 04

    4.变量.函数和运算符 变量 变量声明提前,单var 函数声明 先声明fn再执行 函数声明不应出现在语句块中 函数调用间隔 函数名与左括号间无间隔 立即调用函数 (fuction(){}) 严格模式  ...

  3. ASPxGridView-为每行添加序号

    添加一个新的非绑定列,使用CustomColumnDisplayText事件来分配序号给该列 <dx:GridViewDataTextColumn Caption="序号" ...

  4. tomcat中开启的对SSL(https)的支持

    打开conf/server.xml会发现有下面一段配置被注释着: <!-- <Connector port="8443" protocol="HTTP/1.1 ...

  5. iOS 模态视图转场的动画效果

    ModalViewController * modalView = [[ModalViewController alloc]init]; modalView.modalTransitionStyle ...

  6. SQL Server数据库连接字符串整理

    1.sql验证方式的 Data Source=数据源;Initial Catalog= 数据库名;UserId=sql登录账号;Password=密码; Eg: Data Source=.;Initi ...

  7. leetcode Contains Duplicate python

    Given an array of integers, find if the array contains any duplicates. Your function should return t ...

  8. Android ActionBar详解(二)--->使用ActionBar显示选项菜单

    MainActivity如下: package cc.testsimpleactionbar1; import android.os.Bundle; import android.app.Activi ...

  9. 简单的scrapy实战:爬取腾讯招聘北京地区的相关招聘信息

    简单的scrapy实战:爬取腾讯招聘北京地区的相关招聘信息 简单的scrapy实战:爬取腾讯招聘北京地区的相关招聘信息 系统环境:Fedora22(昨天已安装scrapy环境) 爬取的开始URL:ht ...

  10. smarty函数-转载

    Smarty常用函数 2009-08-13 14:05:55|  分类: Php |举报 |字号 订阅   1 .include_once语句: 引用文件路径,路径必需正确.   eg:include ...