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
int main()
{
int N;
scanf("%d",&N);
N--;
printf("%d\n", N-(N/3));
return 0;
} // 0K 0MS