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. (找出這個(gè)數(shù)列1-N號(hào)元素中能被3整除的有多少個(gè))
Input
Input contains N (1<=N<=231 - 1).
一個(gè)數(shù)乘以10以后,模3后結(jié)果不變,第2,5,8,11,14,17........項(xiàng)滿足要求
#include <stdio.h>
int main()
{
int N;
scanf("%d",&N);
N--;
printf("%d\n", N-(N/3));
return 0;
} // 0K 0MS