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 1131. Copying

why i got WA ?? ( thank you )
Posted by PPJ 9 Nov 2002 22:04
i think it's correc solution
if its algo is worng pls give me some input
thank you
here is my program


#include <stdio.h>
#define min(a,b) ((a<b)?(a):(b))
int ffindlog(long m){
  int i;
  long nn;
  for(i=0,nn=1;nn<m;i++,nn*=2);
  return i;
}
long fgern(long m,int nn){
  int i;
  long sasom;
  sasom=1;
  for(i=0;i<nn;i++,sasom*=2);
  return (sasom-m);
}
int main(void){
  FILE *fi=stdin,*fo=stdout;
  int first;
  long n,k,gern,last;
  fscanf(fi,"%ld %ld\n",&n,&k);
  first=ffindlog(min(k,n));
  gern=fgern(k,first);
  n=n-gern-k;
  last=n/k+((n%k==0)?(0):(1));
  fprintf(fo,"%ld\n",(first+last));
  return fclose(fi)+fclose(fo);
}
ok i get AC
Posted by PPJ 9 Nov 2002 22:11
ok i get  AC
thank you everybody for see my program