codeforces 679 B
2016-06-09 15:26
316 查看
只有2种情况,一直搜索下去就行了 ,一个是剩余的数,一个是答案一,即block,一个是增加的用到的答案
#include <bits/stdc++.h> using namespace std; #define ll long long const int maxn=1e5+10; ll fac[maxn];ll bcnt , bsum; void dfs(ll remain , ll cnt , ll sum){ if (remain <= 0) { if (cnt > bcnt){ bcnt = cnt ; bsum = sum; } else if(cnt == bcnt && sum > bsum){ bsum = sum ; } return ; } // cout<<" remain = "<<remain <<" cnt = "<< cnt <<" sum = "<<sum<<endl; // system (" pause "); int now = lower_bound(fac , fac + maxn - 5, remain) - fac; if(fac[now] > remain){ now --; } // cout << "now = " << now <<endl; // cout << fac[now] << endl; //if(now == -1 ) dfs(0 , cnt + 1, sum + 1); dfs(remain - fac[now] , cnt + 1 ,sum + fac[now]); dfs(fac[now] - 1 - fac[now - 1], cnt + 1 ,sum + fac[now - 1]); } int main () { // fac[0] = 1; for(ll i = 1 ;i <= maxn - 5 ;i ++){ fac[i] = i * i * i; } ll m; while(scanf("%lld" , &m) != EOF){ bcnt = 0 ; bsum = 0; dfs(m , 0 , 0); cout << bcnt << " " <<bsum << endl; } }
相关文章推荐
- Codeforces Round #197 (Div. 2)
- Codeforces Round #198 (Div. 1)
- Codeforces 405E Codeforces Round #238 (Div. 2)E
- Codeforces 407C Codeforces Round #239 (Div. 1)C
- CodeForces 449A - Jzzhu and Chocolate
- CodeForces 449 B. Jzzhu and Cities
- codeforces 618C. Constellation
- Codeforces Round #349 (Div. 2) - C
- Codeforces Round #265 (Div. 2)
- Codeforces #310 div2 C. Case of Matryoshkas
- 状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers
- codeforces 16 Problem E fish
- Codeforces Round332 部分题解
- CodeForces 603A_Alternative Thinking (DP)
- CodeForces 602B_Approximating a Constant Range_DP
- Codeforces round #247 for Div. 2
- Codeforces Round #246 (Div. 2)
- Codeforces #264(div 2)D.Gargari and Permutations
- Codeforces Round #236 (Div. 2)------A,B
- codeforces 257 div2 B