zoukankan      html  css  js  c++  java
  • Codeforces 515C

    CodeForces 515C

    题意:定义f(1234)=1!*2!*3!*4!,现在给一个a,求x的最大整数,满足1,f(a)=f(x) ,在、x的十进制表示中不含1和0

    思路:4!=2!*2!, 8!=2!*2!*2!*7!,6!=3!*5!,9!=7!*2!*3!*3!,尽量分成更多位

    AC代码:

    #include "iostream"
    #include "string.h"
    #include "stack"
    #include "queue"
    #include "string"
    #include "vector"
    #include "set"
    #include "map"
    #include "algorithm"
    #include "stdio.h"
    #include "math.h"
    #pragma comment(linker, "/STACK:102400000,102400000")
    #define ll long long
    #define endl ("
    ")
    #define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
    #define mem(a,x) memset(a,x,sizeof(a))
    #define mp(x,y) make_pair(x,y)
    #define pb(x) push_back(x)
    #define ft (frist)
    #define sd (second)
    #define lrt (rt<<1)
    #define rrt (rt<<1|1)
    using namespace std;
    const long long INF = 1e18+1LL;
    const int inf = 1e9+1e8;
    const int N=1e5+100;
    const ll mod=1e9+7;
    
    char s[20];
    int n,ans[105];
    int main(){
        ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
        cin>>n>>s+1;
        int l=0;
        for(int i=1; i<=n; ++i){
            if(s[i]=='0' || s[i]=='1') continue;
            if(s[i]=='4'){
                ans[++l]=2,ans[++l]=2,ans[++l]=3;
            }
            else if(s[i]=='8'){
                ans[++l]=2,ans[++l]=2,ans[++l]=2,ans[++l]=7;
            }
            else if(s[i]=='6'){
                ans[++l]=3,ans[++l]=5;
            }
            else if(s[i]=='9'){
                ans[++l]=7,ans[++l]=2,ans[++l]=3,ans[++l]=3;
            }
            else ans[++l]=s[i]-'0';
        }
        sort(ans+1,ans+1+l);
        for(int i=l; i>=1; --i) cout<<ans[i];
        return 0;
    }
  • 相关阅读:
    继承
    面向对象_封装练习
    ajax分页与组合查询配合使用
    Linq的分页与组合查询的配合使用
    发送邮件和数据导出
    GridView的使用
    母版页的使用
    DIV+CSS命名规范
    Ajax基础
    jQuery动画效果
  • 原文地址:https://www.cnblogs.com/max88888888/p/7306091.html
Copyright © 2011-2022 走看看