Skip to content

Instantly share code, notes, and snippets.

@zsrinivas
Created May 15, 2014 18:13
Show Gist options
  • Save zsrinivas/fef18841cd6ae152ef78 to your computer and use it in GitHub Desktop.
Save zsrinivas/fef18841cd6ae152ef78 to your computer and use it in GitHub Desktop.
/*wrong code*/
#include <stdio.h>
#include <math.h>
int main(int argc, char const *argv[])
{
long long int i,n,k,m,t,nin,printout;
scanf("%lld", &t);
while(t--)
{
scanf("%lld%lld%lld",&n,&k,&m);
nin=n;
for (i = 0; i < m; ++i)
{
if (n%k)
break;
n/=k;
}
if (i==m)
i--;
if ((m-i-1)%2)
printout=n;
else
printout=n*k;
printf("%lld\n", printout);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment