Thursday, February 5, 2015

Solution of 379A. New Year Candles (Codeforces)

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define sf scanf
#define pf printf
typedef long long ll;

int main()
{
    int a, b, div, mod;
    sf("%d%d", &a, &b);
    int sum = a;
    while(a>=b)
    {
        div = (a/b);
        sum = sum + div;
        mod = (a%b);
        a= (div+mod);
    }
    pf("%d\n", sum);
}

1 comment:

  1. api problem tate ki bolse bujhi nai......pls explain...

    ReplyDelete

Compare equality of two string in C

#include <stdio.h> #include<string.h> int main() {     char* country = "Bangladesh";     char* country2;     ...