URAL-1748 The Most Complex Number

http://blog.csdn.net/miaomiao_ymxl/article/details/52443371

My Mom传送门~~~~~十分十分的详细!!!

我就不做解释了,直接给代码好了(好迷啊(迷惑脸....))

[[[这里给出日常错误点吧~

Hans做此题wa了无数次,最后终于发现了错误!!!我!没写!lld!写的是!d!QuQ心好痛........

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

long long n, ans, cnt;
const int ss[16] = {1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};

void dfs(long long now_num, long long k_ss, long long now_cnt, int maxxcnt){
	if(k_ss >= 16) return;
	if(now_cnt > cnt || (now_cnt == cnt && now_num < ans)){
        cnt = now_cnt;
        ans = now_num;
   	}
    long long  temp = ss[k_ss];
    for(long long i = 1; i <= maxxcnt; i++){
        if(temp > n / now_num)
            break;
        dfs(now_num*temp, k_ss+1, now_cnt*(i+1), i) ;
   		temp *= ss[k_ss];
    }
}


int main(){
	int t;
	scanf("%d", &t);
	while(t--){
	    scanf("%lld", &n);
	    ans = cnt = 1LL;
	    dfs(1, 1, 1, 50);
	    printf("%lld %lld\n", ans, cnt);
	}
	
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值