hiho week 209 register

Ended

Participants:113

Verdict:Memory Limit Exceeded
Score:80 / 100
Submitted:2018-07-03 11:46:01

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class sol{
    private:
        int n;
        int length;
        vector<int> ValueofPower2;
        vector<int> dp;
    public:
        void init(int cinNum){
            n=cinNum;
            int i=0;
            int value=2;
            while(value<cinNum){
                ValueofPower2.push_back(value);
                value*=2;
            }
            ValueofPower2.push_back(value);
            length=ValueofPower2.size();
            vector<int> tmp(n+1,10);
            dp=tmp; 
            dp[0]=0;        
        }
        bool isPower2(int n){
            for(int i=0;i<length;i++){
                if(n==ValueofPower2[i])
                    return true;
            }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX