【codeforce】-#669A-Little Artem and Presents(數學,找規律)
Little Artem got n stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the present, rather than the value of that present, so he wants to give her stones as many times as possible. However, Masha remembers the last present she received, so Artem can't give her the same number of stones twice in a row. For example, he can give her 3
How many times can Artem give presents to Masha?
InputThe only line of the input contains a single integer n (1 ≤ n ≤ 109) — number of stones Artem received on his birthday.
OutputPrint the maximum possible number of times Artem can give presents to Masha.
1output
1input
2output
1input
3output
2input
4output
3Note
In the first sample, Artem can only give 1 stone to Masha.
In the second sample, Atrem can give Masha 1 or 2 stones, though he can't give her 1 stone two times.
In the third sample, Atrem can first give Masha 2
In the fourth sample, Atrem can first give Masha 1 stone, then 2 stones, and finally 1 stone again.
找數學規律,112334556778.........#include<cstdio>
int main()
{
int n,x,y,ans;
while(~scanf("%d",&n))
{
x=n%3;
y=n/3;
if(x!=0)
ans=2*y+1;
else
ans=2*y;
printf("%d\n",ans);
}
return 0;
}