UVa 13090 - Base of MJ

// the solution will be ans=N/D, but for the base it will be ans=(N-1)/D.
// Because if N=30 and D=3, then the real answer will be 10 cause of we have total 10 numbers which summation of digits is divisible by 3 from 1 to 30
// But the problem is 30, 3+0=3 no doubt it is divisible by 3 but 30 is represented by base 31 which is not valid for N
//because your N=30, so the answer will be (N-1) / D :)

#include<bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back

typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;

const int mod = 1000007;
const int high = 100;

int main()
{
    int t , tc=0;
    LL N , D, ans;
    sf("%d", &t);
    while(t--)
    {
        sf("%lld %lld", &N, &D);

        ans = (N - 1) / D;

        pf("Case %d: %lld\n", ++tc , ans);
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number