zoukankan      html  css  js  c++  java
  • HDU 4228 Flooring Tiles 反素数

    推出了结论,万万没想到最后用搜索。。

    还想dp来着。。

    #include <cstdio>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    #include <math.h>
    #include <set>
    #include <vector>
    #include <map>
    using namespace std;
    #define ll long long
    #define N 1000005
    ll prime[N],primenum;//有primenum个素数 math.h
    void PRIME(ll Max_Prime){
    	primenum=0;
    	prime[primenum++]=2;
    	for(ll i=3;i<=Max_Prime;i+=2)
    	for(ll j=0;j<primenum;j++)
    		if(i%prime[j]==0)break;
    		else if(prime[j]>sqrt((double)i) || j==primenum-1)
    		{
    			prime[primenum++]=i;
    			break;
    		}
    }
    ll n, ans, sum;
    void dfs(ll a,ll s, ll t, ll l){
    	if(s>n<<1)return ;
    	if(s==2*n || s==2*n-1){
    		ans = min(ans, a);
    		return ;
    	}
    	if(t>20)return;
    	for(ll i = 1; i <= l; i++) {
    	a *= prime[t];
    	dfs(a,s*(i+1), t+1,i);
    	}
    }
    int main(){
    	ll i,j,u,v;
    	PRIME(100);
    	while(cin>>n, n) {
    	ans = 1e18;
    	dfs(1,1,0,60);
    	cout<<ans<<endl;
    	}	
    	return 0;
    }


  • 相关阅读:
    vue--组件基础
    vue中的一些知识点--多看文档
    关于组件--React
    数组方法-->map()
    正则表达式使用
    border-image 和 border-color 不能同时使用问题
    gulp
    oninput 中文输入
    linux文档权限
    为什么使用 use strict
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4297055.html
Copyright © 2011-2022 走看看