Advertisement
a53

Catalin_si_greselile_MVT

a53
Jan 14th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define NMax 1000001
  4. using namespace std;
  5. ifstream f("greselile.in");
  6. ofstream g("greselile.out");
  7.  
  8. int dp[NMax],p[NMax];
  9. int nr,n,t,x;
  10.  
  11. int main()
  12. {
  13. f >> n >> t;
  14. for(int i = 2; i <= n; i++){
  15. for(int j = i + i; j <= n; j += i){
  16. dp[j] = max(dp[i] + 1,dp[j]);
  17. }
  18. }
  19.  
  20. for(int i = 1; i <= t; ++i){
  21. f >> x;
  22. g << dp[x] + 1<< '\n';
  23. }
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement