[2126] JZOJ most about the number and

  Subject to the effect

      Select S and not more than several different positive integers, such that the number of all divisors (excluding itself) and the maximum sum.

  analysis

      We break out the factor of the merger, there is an unknown array, then we could have started our Di fart! ! (Bag), we can

      Put it into backpack 01:

      f[j]=max(f[j],f[j-1]+sum[i]);

    then:

  code

    

 1 #include<cstdio>
 2 #include<iostream>
 3 using namespace std;
 4 
 5 int f[1001000];
 6 int ans;
 7 int n;
 8 int sum[1001000];
 9 int main(){
10     freopen("maxsum.in","r",stdin);
11     freopen("maxsum.out","w",stdout);
12     cin>>n;
13     for(int i=1;i<=n/2;i++){
14         for(int j=i*2;j<=n;j+=i){
15             sum[j]+=i;
16         }
17     }
18     for(int i=1;i<=n;i++){
19         for(int j=n;j>=1;j--){
20             if(j>=i)
21                 f[j]=max(f[j],f[j-i]+sum [i]);
22              years = max (years f [j]);
23          }
 24      }
 25      cout << years;
26 }

Flood

Guess you like

Origin www.cnblogs.com/WestJackson/p/11372310.html