Thursday, November 16, 2017

1051 - Div 3 COJ Problem Solution


http://coj.uci.cu/24h/problem.xhtml?pid=1051



In C++...........

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

int main() {
    // your code goes here
    long long n,ans;
    cin>>n;
    ans=n-n/3;
    if(n%3!=0)
        ans--;
   
    cout<<ans<<endl;
    return 0;
}

1 comment:

  1. What was you thinking to get this formula, can you tell me

    ReplyDelete