Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8022751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:21:38+00:00 2026-06-04T22:21:38+00:00

I was doing a question on spoj cubefr . I have written a code

  • 0

I was doing a question on spoj cubefr .

I have written a code but i don’t know hy i am getting wrong answer always can anyone tell me please

#include<stdio.h>
#include<stdlib.h>

int main()
{   
    int arr[1000001];
    int i,root,temp,j=0;

    for(i=2;i<=100;i++)
    {
        temp = i*i*i;
        root = temp;
        while(root <=1000000)
        {
            arr[root] = 1;
            root = root + temp;

        }

    }

    int a[1000001];
    a[0]=0;
    a[1]=1;
    int b=2,n;
    int cnt=0;

    for(j=2;j<=1000000;j++)
    {
        if (arr[j] != 1)
        {
            a[b] = j-cnt;
            b++;
        }
        else
        {
            b++;
            cnt++;
        }

    } 
    int k,t;
    scanf("%d",&t);
    for(k=1;k<=t;k++)
    {
        scanf("%d",&n);
            if (arr[n] == 1)
            {
                printf("Case %d: Not Cube Free\n", k);
            }
            else
            {
                printf("Case %d: %d\n", k, a[n]);
            }
    }
    return 0;
}   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:21:39+00:00Added an answer on June 4, 2026 at 10:21 pm

    Local variables are not guaranteed to be zeroed on program execution. If you want to be sure that a and arr are zeroed, either make them global or use memset. I would do both by the way. It is generally a good idea to have big arrays in global scope(for competitions of course) and using memset you create a good routine that will help you for some multi-test case problems. Trust me – painful experience.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Re-doing this question since I don't know if I was getting my point across
Another jQuery noob question - what am I doing wrong?? I have some HTML
I am doing project euler question 33 and have divised a refactor to solve
I have a question regarding the method i am using for doing Business Rule
I got a question when I was doing some Array in PHP. I don't
I have been doing some functional programming and had a question. Perhaps I might
Hopefully this question has an easy answer. It's probably something stupid I'm doing! In
I was doing interview question on priority queues and have a simple question I
I have a question about doing a query through a few associations using Ruby
As question states, I am doing homework which have 2 variables BOOK, and MAGAZINE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.