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号元素中能被3整除的有多少个)
Input
Input contains N (1<=N<=231 - 1).
一个数乘以10以后,模3后结果不变,第2,5,8,11,14,17........项满足要求
#include <stdio.h>
int main()
{
int N;
scanf("%d",&N);
N--;
printf("%d\n", N-(N/3));
return 0;
} // 0K 0MS