URI ONLINE JUDGE SOLUTION 1306 - Online Judge

Latest

This is an Online Judge Solution Base Site. We can discuss & Solve any contest solution in Programming.

Friday, April 10, 2020

URI ONLINE JUDGE SOLUTION 1306

Problem Number: 1306
Problem Name: Numbering Roads
Author’s Name: By Shahriar Manzoor Bangladesh
Timelimit: 1
Problem Category: AD-HOC
Problem Source: https://www.urionlinejudge.com.br/judge/en/problems/view/1306

Solution:

#include <stdio.h>

int main(){
    int r, n, j;
    int i = 1;
    int flag;
   
    while(1){
        scanf("%d %d",&r, &n);
        if(r == 0 && n == 0) break;
        flag = 0;
       
        if(n >= r){
             printf("Case %d: 0n", i);
        }else{
               for(j = 1; j < 27;  j++){
                     if(n*(j+1) >= r){
                              printf("Case %d: %dn", i, j);
                              flag = 1;
                              break;
                     }
               }
               if(flag == 0) printf("Case %d: impossiblen", i);
        }
        i++;
    }
    return 0;
}

No comments:

Post a Comment

Thanks..