【SGU】 105. Div 3

来源:互联网 发布:设置环境变量 linux 编辑:程序博客网 时间:2024/05/17 06:23
/** *  @author      johnsondu *  @createTime  2015-8-16 17:04    @problem     SGU Div 3    @url         http://acm.sgu.ru/problem.php?contest=0&problem=105    @description math, print first 20 elements and find the rule behind it.
                 0 1 2 2 3 4 4 5 6 6 ... */#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <stack>#include <queue>#include <map>#include <vector>using namespace std;int main(){    int n;    while(cin >> n) {        if (n < 4) cout << n - 1 << endl;        else {            if (n % 3 == 0 || n % 3 == 1)                cout << n / 3 * 2 << endl;            else                 cout << n / 3 * 2 + 1 << endl;        }    }    return 0;}

0 0
原创粉丝点击