sgu105-数学

105. Div 3

time limit per test: 0.25 sec. 
memory limit per test: 4096 KB

There is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first N elements of that sequence. You must determine amount of numbers in it that are divisible by 3.

Input

Input contains N (1<=N<=231 - 1).

Output

Write answer to the output.

Sample Input

4

Sample Output

2
 
我是根据发现规律解出来的
      
      
      
      
1 0
2 1
3 2
4 2
5 3
6 4
7 4
8 5
9 6
10 6
11 7
12 8
#include <iostream>
using namespace std;

int main()
{
    int N;
    cin >> N;
	
    int ans = 0;  
    if (N % 3 == 2)  
        ans++;  
    ans += 2 * (N / 3);  
    cout << ans; 

    return 0;
}


你可能感兴趣的:(sgu)