Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- unsigned long long int res = 1;
- int n, k, n_iterator, pom=1, flag = 1;
- while(scanf("%d %d", &n, &k)>0){
- if(k>=0 && n>=k){
- n_iterator = n;
- while (n_iterator != 1 || flag){
- res = res*n_iterator/pom;
- if(n_iterator >1)
- n_iterator--;
- if(pom < k && flag==1){
- pom++;
- }
- else if (flag==1) {
- pom = 1;
- flag = 2;
- }
- else if (pom < n-k && flag==2){
- pom++;
- }
- else {
- pom = 1;
- flag = 0;
- }
- }
- printf ("%lu\n", res);
- } else printf ("zly vstup\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement