记录编号 123131 评测结果 AAAAAAAAAA
题目名称 [RQNOJ 166] 隐藏的信息 最终得分 100
用户昵称 GravatarHouJikan 是否通过 通过
代码语言 C++ 运行时间 0.014 s
提交时间 2014-09-25 21:23:57 内存使用 0.28 MiB
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <ctime>
#include <iterator>
#include <functional>
#define pritnf printf
#define scafn scanf
#define For(i,j,k) for(int i=(j);i<=(k);(i)++)
using namespace std;
typedef long long LL;
typedef unsigned int Uint; 
const int INF=0x7ffffff;
//==============struct declaration==============

//==============var declaration=================
const int MAXN=20;
string s;
char num[MAXN];
int a,b,Lcm;
//==============function declaration============
int gcd(int a,int b){if (a<b) a^=b^=a^=b;return a%b==0?b:gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
//==============main code=======================
int main()
{  
  string FileName="lcsa";//程序名 
  string FloderName="COGS";//文件夹名 
  freopen((FileName+".in").c_str(),"r",stdin);
  freopen((FileName+".out").c_str(),"w",stdout);
#ifdef DEBUG  
  system(("cp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\standard.cpp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\submit.txt").c_str());
  clock_t Start_Time=clock();
#endif    
  cin>>s>>a>>b;
  Lcm=1;
  For(i,a,b)
    Lcm=lcm(Lcm,i);
  strcpy(num,s.c_str());
  sort(num,num+s.length());
  int Up=1;
  int len=s.length();
  For(i,2,len)
    Up*=i;
  bool suc=false;
  For(i,1,Up){
    int sum=0;
    For(j,0,len-1)
      sum=sum*10+num[j]-'0';
    if (sum%Lcm==0)
      printf("%d\n",sum),suc=true;
    next_permutation(num,num+len);
  }
  if (!suc)
    cout<<"No answer\n";
#ifdef DEBUG  
  clock_t End_Time=clock();
  printf("\n\nTime Used: %.4lf Ms\n",double(End_Time-Start_Time)/CLOCKS_PER_SEC);
#endif    
  return 0;
}
//================fuction code====================