(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 ...
随机推荐
- 1503171912-ny-一道水题
一道水题 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描写叙述 今天LZQ在玩一种小游戏,可是这游戏数有一点点的大,他一个人玩的累.想多拉一些人进来帮帮他.你能写一个程序帮 ...
- uva10617 - Again Palindrome(dp)
再次回文 输入:标准输入 输出:标准输出 时间限制: 2秒 是àpalindorme的读取相同的从左边,因为它从右侧的一个或多个字符的序列.例如,Ž,TOT和女士的 回文,但是,ADAM是不是. 给定 ...
- 初识Maven
今天开始学习怎样使用maven,听起来挺神奇的东西,我们来一步一步的加以剖析. Maven的一些具体的论文的东西,网上很多博客介绍,这里我就不逐一介绍,下面我们从安装maven开始讲解: (1)Mav ...
- 交互设计师谈颠覆式创新 | Think different
作者:Teambition 交互设计师 樊伟 本文由 Teambition 原创.转载请注明出处,附原文链接 题图:by Ed Chao 我们不需要像主流市场的大公司一样做类似相扑的庞大,而是需要像柔 ...
- 配置tomcat的https通信(单向认证)
1.首先用jdk带的工具生成证书库 打开cmd命令行窗口,cd 到tomcat安装目录的bin下面执行 keytool -v -genkey -alias tomcat -keyalg RSA -ke ...
- (转)eclipse 启动参数介绍(如添加插件时,如果不显示,则使用eclipse -clean启动)
本文转载自:http://hi.baidu.com/dd_taiyangxue/blog/item/08950f3991b4e8c9d46225c8.html 其实,Eclipse是一个可以进行非常灵 ...
- c# json处理(转)
一.C#处理简单json数据 json数据:{"result":"0","res_info":"ok","qu ...
- C/C++常用编辑器
VIM ,www.vim.org/ Emacs, www.gnu.org/software/emacs/ notepad++,www.notepad-plus-plus.org/ Textmate,h ...
- bzoj 2542: [Ctsc2001]终极情报网 费用流
题目链接 2542: [Ctsc2001]终极情报网 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 321 Solved: 125[Submit][S ...
- JS表格排序
var employees = [] employees[0] = { name: "George", age: 32, retiredate: "March 12, 2 ...