Thursday, May 11, 2017

URI 1169 Solution in C, C++ | URI Grains in a Chess Board Solution

URI 1169 Solution in C, C++ | URI Grains in a Chess Board Solution

URI Online Judge Solution  Grains in a Chess Board | Mathematics
URI Main Problem Link - https://www.urionlinejudge.com.br/judge/en/problems/view/1169

Problem Name: URI Problem 1169
Problem Number : URI Problem 1169 Solution
Online Judge : URI Online Judge Solution
Level: Mathematics
Solution Language : C, C plus plus

URI 1169 Solution in C, C++ | URI Grains in a Chess Board Solution

URI Solution 1169 Solution in C:

#include <stdio.h>
#include <math.h>

int main(){
    int n, x, i;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
            scanf("%d", &x);
            printf("%lld kg\n", (long long)(pow(2,x)/12000));
    }
    
    return 0;
}


URI Solution 1169 Solution in C++:

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
 int n, x;
 unsigned long long int q;
 
 cin >> n;
 
 for(int i = 0; i < n; ++i)
 {
  q = 1;
  cin >> x;
  
  if(x == 64){
   cout << "1537228672809129 kg" << endl;
  }else{
   for(int j = 0; j < x; ++j){q *= 2;}
   q = ((q/12)/1000);
   cout << fixed << setprecision(0) << q << " kg" << endl;
  }
 }
 
 return 0;
} 


Tags: Uri solve , Uri solution, URI oj Solve, URI Online Judge Solution list, URI 1169 solution, URI Grains in a Chess Board solution

No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.