(水题) Div 3 -- SGU -- 105

链接:

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
", sum);
     }
    return 0;
 }
勿忘初心
原文地址:https://www.cnblogs.com/YY56/p/4815068.html