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.
1 <= N <= 2147483647
打表找规律就出来了
#include <cstdio>
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n, ans;
scanf("%d", &n);
switch(n % 3) {
case 0: ans = 2; break;
case 1: ans = 0; break;
case 2: ans = 1; break;
}
ans += (n-1) / 3 * 2;
printf("%d\n", ans);
#ifndef ONLINE_JUDGE
fclose(stdin);
fclose(stdout);
#endif
return 0;
}