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

Common Board

Simple popular program 1009 and WA? Why?
Posted by Kirill 2 Feb 2006 18:26
Please help. Whats wrong?!

#include <stdio.h>

int Pow(int N,int K) {
    int P=1;
    while (N>0) {
          P=P*K;
          N--;
    };
    return P;
}

int main() {
    int N,K;
    scanf("%d %d",&N,&K);
    if (N==1) printf("%d\n",Pow(N,K));
    else if (N==2) printf("%d\n",Pow(N,K)-K);
    return 0;
}