ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1073. Square Country

Why is my solution wrong?
Posted by PopPy Mwit#17 7 Apr 2008 12:29
#include<stdio.h>
long func(long a,long b,long c);
long pow(long x,long y);
long result=1;
long n;
long k;
int count=0;
int main(){
    scanf("%ld",&n);
    k=n;
    for(;k>0;){
               k-=pow((long)sqrt(k),2);;
               result=1;
               count++;
    };
    func(n,0,(long)sqrt(n));
    printf("%d",count);
    for(;;);
};
long pow(long x,long y){
     if (y!=0) return x*pow(x,y-1);
     return 1;
};
long func(long a,long b,long c){
     int i;
     if (b>=count || a<0) return 0;
     if (b<count && a==0){
        count=b;
        printf("%ld %ld %ld\n",a,b,c);
     };
     for(i=c;i>0;i--) func(a-pow(i,2),b+1,i);
};