Please read the new rule regarding the restriction on the use of AI tools. ×

ric_hagsfd's blog

By ric_hagsfd, history, 20 months ago, In English

hi guys, Im new to codeforce. My question is for problem# 318A EVEN ODD I've used ordered map in this question but not getting the answer. Please do let me know where Im wrong........

int main() { int i, j; map<int, int> m; int n, k; cin>>n>>k;

for (i =1, j=1; j <=n; i++, j+2)
{
    m[i]= j;
}

for (i, j=2; j <=n; i++, j+2)
{
    m[i]= j;
}

auto it= m.find(k);
if(it!=m.end())
{ 
    cout<<endl<<(*it).second;

}

}

  • Vote: I like it
  • -8
  • Vote: I do not like it

| Write comment?
»
20 months ago, # |
  Vote: I like it +8 Vote: I do not like it

the number n has upper limit of 10^12 which is hard to store, you have to find a way to do this task without any data structure.

»
20 months ago, # |
  Vote: I like it +8 Vote: I do not like it

if you search about limits for datatypes in c++ ,it will help you to solve it