链接:
http://vj.acmclub.cn/contest/view.action?cid=168#problem/E
问题描述
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; }
勿忘初心