/* Pattern is 0 1 1 0 1 1 0 1 1... * 0 for not divisible by 3 * 1 for divisible by 3 */ #include<cstdio> int main() { int n; while(scanf("%d",&n)!=EOF) printf("%d\n",((n/3)<<1)+((n%3)-1>0?(n%3-1):0)); return 0; } |
/* Pattern is 0 1 1 0 1 1 0 1 1... * 0 for not divisible by 3 * 1 for divisible by 3 */ #include<cstdio> int main() { int n; while(scanf("%d",&n)!=EOF) printf("%d\n",((n/3)<<1)+((n%3)-1>0?(n%3-1):0)); return 0; } |