Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- long long s,n,k;
- int main() {
- scanf("%lli %lli",&n,&k);
- s = 1;
- while (n>0) {
- if (s > 1e18/n) {
- s = -1;
- break;
- }
- s = s*n;
- n = n - k;
- }
- if (s>0)
- printf("%lli\n",s);
- else
- printf("overflow");
- return 0;
- }
Add Comment
Please, Sign In to add comment