URI Online Judge Solution 1023 Drought - Solution in C, C++, Java, Python and C# - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Tuesday, September 19, 2017

URI Online Judge Solution 1023 Drought - Solution in C, C++, Java, Python and C#

URI Online Judge Solution 1023 Drought  - Solution in C, C++, Java, Python and C#

URI Online Judge Solution 1023 Drought   | Beginner
URI Problem Link - https://www.urionlinejudge.com.br/judge/en/problems/view/1023

Problem Name: 1023 Drought  solution
Problem Number : URI - 1023 Drought  code
Online Judge : URI Online Judge Solution
Category: Data Structure
Solution Language : C,C plus plus, java, python, c#(c sharp)

URI Online Judge Solution 1023 Drought  - Solution in C, C++, Java, Python and C#

URI 1023 problem simple input output:

Input SampleOutput Sample
3
3 22
2 11
3 39
5
1 25
2 20
3 31
2 40
6 70
0
Cidade# 1:
2-5 3-7 3-13
Consumo medio: 9.00 m3.

Cidade# 2:
5-10 6-11 2-20 1-25
Consumo medio: 13.28 m3.

URI Solution 1023 Drought   Code in C++ / URI 1023 code in CPP:


#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

int arr[300];

int main(int argc, char const *argv[])
{
 int i, j, n, c = 1, a, b, ta, tp, fp;
 double ip;
 bool bo = false;

 while(scanf("%d", &n) && n)
 {
  if(bo) printf("\n");
  bo = true;

  ta = tp = 0;
  memset(arr, 0, sizeof arr);

  for (i = 0; i < n; ++i)
  {
   scanf("%d %d", &a, &b);
   ta += b;
   tp += a;
   arr[b/a] += a;
  }

  printf("Cidade# %d:\n", c); c++;

  for(i = 0, j = 0; i < 300; i++)
  {
            if(arr[i] > 0){
                if(j != 0)
                    printf(" ");
                printf("%d-%d", arr[i], i);
                j++;   
            }  
        }
  printf("\n");

  fp = (int) (modf ((double)ta/tp, &ip) * 100);

  if(fp < 10) printf("Consumo medio: %d.0%d m3.\n", (int)ip, (int)fp);
  else printf("Consumo medio: %d.%d m3.\n", (int)ip, (int)fp);
 }

 return 0;
}

URI Solution 1023 Drought   Code / URI 1002 solution in Java:



URI Solution 1023 Drought   Code / URI 1002 solution in  Python:

URI Solution 1023 Drought   Code / URI 1002 solution in  C# (C Sharp):


Demonstration:

Just implement this in coding. Since having any problem just put a comment below. Thanks



Tags: URI Online Judge Solution, URI OJ Solution list, URI Problems Solution, URI solver, URI all problem solution list, URI 1023 Drought   code in C, URI 1023 Drought   code in C++, URI 1023 Drought   solution in C, URI solution, URI 1023 Drought   solution in C,URI 1023 Drought   solution in C++-CPP,URI 1023 Drought   solution in C# (C sharp),URI 1023 Drought   solution in Java,URI 1023 Drought   solution in Python,

No comments:

Post a Comment