UVA 11609 - Teams

UVA Sep 01, 2020

Problem PDF

Solution:

/*-----------------------------------------------*/
//Problem Setter: Towhidul Islam Talukdar
//Problem Name  : Teams
//Uva Problem No: 11609
//Type          : Math,Bigmod,Summations.
//Author        : Shipu Ahamed
//University    : BUBT
//E-mail        : [email protected]
/*-----------------------------------------------*/
//Hints :http://www.outsbook.com/uva/?page=latest_post&category=-1&id=11609
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define ll long long
#define sc scanf
#define pf printf
#define pi 2*acos(0.0)
#define mod 1000000007
using namespace std;
ll bigmod (ll b, ll p)
{
    if (p==0)
    return 1;
    if (p==1)
    return b;
    if (p % 2==0 ) {
        ll r = bigmod(b, p / 2) % mod;
        return (r*r) % mod;
    }
    else
    return (bigmod (b, p - 1) % mod) * (b % mod);
}
int main()
{
    int t,no=0;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        pf("Case #%d: ",++no);
        cout<<((n%mod)*bigmod(2,n-1)%mod)%mod<
https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/11609/11609.cpp

Tags

Shipu Ahamed

CSPO® | Partly Product, Project Manager and Partly Software Engineer.

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.