hdu1015
来源:互联网 发布:招淘宝代理 编辑:程序博客网 时间:2024/05/16 10:45
#include <iostream>
#include<cstring>
//#include <bits/stdc++.h>//包含所有头文件,可惜hdu不识别
#include<stdio.h>
//看懂题意,直接五个循环,不超时
#include<algorithm>
#include<iostream>
using namespace std;
bool cmp(char a,char b)
{
return a>b;
}
int main()
{
int target;
char s[20];
while(cin>>target&&target)
{
cin>>s;
int flog=0;
int len=strlen(s);
sort(s,s+len,cmp);
for(int a=0; a<len; a++)
{
for(int b=0; b<len; b++)
{
if(b==a)continue;
for(int c=0; c<len; c++)
{
if(c==b||c==a)continue;
for(int d=0; d<len; d++)
{
if(d==a||d==b||d==c) continue;
for(int e=0; e<len; e++)
{
if(e==a||e==b||e==c||e==d) continue;
int ta=s[a]-'A'+1;
int tb=s[b]-'A'+1;
int tc=s[c]-'A'+1;
int td=s[d]-'A'+1;
int te=s[e]-'A'+1;
if(ta-tb*tb+tc*tc*tc-td*td*td*td+te*te*te*te*te==target)
{
flog=1;
//cout<<
printf("%c%c%c%c%c\n",s[a],s[b],s[c],s[d],s[e]);//printf输出C C++均可用
break;
}
}
if(flog)break;
}
if(flog)break;
}
if(flog)break;
}
if(flog)break;
}
if(flog==0)cout<<"no solution"<<endl;
}
return 0;
}
#include<cstring>
//#include <bits/stdc++.h>//包含所有头文件,可惜hdu不识别
#include<stdio.h>
//看懂题意,直接五个循环,不超时
#include<algorithm>
#include<iostream>
using namespace std;
bool cmp(char a,char b)
{
return a>b;
}
int main()
{
int target;
char s[20];
while(cin>>target&&target)
{
cin>>s;
int flog=0;
int len=strlen(s);
sort(s,s+len,cmp);
for(int a=0; a<len; a++)
{
for(int b=0; b<len; b++)
{
if(b==a)continue;
for(int c=0; c<len; c++)
{
if(c==b||c==a)continue;
for(int d=0; d<len; d++)
{
if(d==a||d==b||d==c) continue;
for(int e=0; e<len; e++)
{
if(e==a||e==b||e==c||e==d) continue;
int ta=s[a]-'A'+1;
int tb=s[b]-'A'+1;
int tc=s[c]-'A'+1;
int td=s[d]-'A'+1;
int te=s[e]-'A'+1;
if(ta-tb*tb+tc*tc*tc-td*td*td*td+te*te*te*te*te==target)
{
flog=1;
//cout<<
printf("%c%c%c%c%c\n",s[a],s[b],s[c],s[d],s[e]);//printf输出C C++均可用
break;
}
}
if(flog)break;
}
if(flog)break;
}
if(flog)break;
}
if(flog)break;
}
if(flog==0)cout<<"no solution"<<endl;
}
return 0;
}
0 0
- hdu1015
- hdu1015
- hdu1015
- hdu1015
- hdu1015
- hdu1015
- HDU1015
- HDU1015
- hdu1015
- hdu1015
- HDU1015
- HDU1015
- HDU1015 Safecracker
- hdu1015深搜
- HDU1015 Safecracker
- hdu1015(Safecracker )
- Safecracker HDU1015
- hdu1015(枚举)
- EOJ 3260:袋鼠妈妈找孩子
- 深刻剖析spring三种注入方式以及使用注解的原理
- windows 10修改默认的浏览器无效
- SSM配置Ueditor实现图片的上传<一>
- 常见对象-字符串反转功能案例
- hdu1015
- k8s scheduler不同namespace同名node节点调度异常
- http协议中的状态码
- 【C语言】调整数组使奇数全部都位于偶数前面
- 生产环境上的HADOOP安装部署注意事项(HDP版)
- MySQL安装、常用命令、使用遇到问题及解决
- Java 中字符串的不变性
- 索引概述和索引分类
- hadoop安装与配置