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<stdio.h>
int main(){
int n,i,t,j;
scanf("%d",&n);
i=n/3;
j=n%3;
if(j==0||j==1)
t=2*i;
if(j==2)
t=2*i+1;
printf("%d\n",t);
return 0;
}

696

被折叠的 条评论
为什么被折叠?



