Monday, March 16, 2015

492A. Vanya and Cubes (Codeforces)

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

int main()
{
    int n, sum , temp, count, i;
    sf("%d", &n);
    count = 0;
    sum = 0;
    temp = 0;
    for(i=1;;i++)
    {
        sum = sum + i;
        temp = sum + temp;
        if(temp>n)
        {
            break;
        }
        count++;
    }
    pf("%d\n", count);
}

No comments:

Post a Comment

Compare equality of two string in C

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