链接:

http://vj.acmclub.cn/contest/view.action?cid=168#problem/E

 

时限:250MS     内存:4096KB     64位IO格式:%I64d & %I64u

问题描述

 

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

还以为是每位数代表一个数呢!唉,题没懂

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<queue>

using namespace std;

const long long MOD = 1000000000;

 int main()
 {
     int n;

     while(scanf("%d", &n), n)
     {
         int sum = n/3*2;
         if(n%3==2)
            sum ++;

         printf("%d\n", sum);
     }
    return 0;
 }

 

posted on 2015-09-17 01:12  栀蓝  阅读(132)  评论(0编辑  收藏  举报

levels of contents