Codeforces 669A Little Artem and Presents(数量不同送礼物)
2016-08-11 11:04
656 查看
http://codeforces.com/problemset/problem/669/A
A. Little Artem and Presents
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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 stones, then 1 stone,
then again 3 stones, but he can't give her 3 stones
and then again 3 stones right after that.
How many times can Artem give presents to Masha?
Input
The only line of the input contains a single integer n (1 ≤ n ≤ 109) —
number of stones Artem received on his birthday.
Output
Print the maximum possible number of times Artem can give presents to Masha.
Examples
input
output
input
output
input
output
input
output
Note
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 stones, a then 1 more
stone.
In the fourth sample, Atrem can first give Masha 1 stone, then 2 stones,
and finally 1 stone again.
题意:
送礼物的时候,今天不能够和昨天送的数量一样多,否则就达不到目的(不知道什么目的,没翻译明白),看来为了追上自己喜欢的女孩,
要好好学习数学昂。
思路:
慢慢写吧
就会发现分组的依据是能否被 3 整除,能被整除的都会比之前出现的数字多出一个方案,
则有:
Code:
A. Little Artem and Presents
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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 stones, then 1 stone,
then again 3 stones, but he can't give her 3 stones
and then again 3 stones right after that.
How many times can Artem give presents to Masha?
Input
The only line of the input contains a single integer n (1 ≤ n ≤ 109) —
number of stones Artem received on his birthday.
Output
Print the maximum possible number of times Artem can give presents to Masha.
Examples
input
1
output
1
input
2
output
1
input
3
output
2
input
4
output
3
Note
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 stones, a then 1 more
stone.
In the fourth sample, Atrem can first give Masha 1 stone, then 2 stones,
and finally 1 stone again.
题意:
送礼物的时候,今天不能够和昨天送的数量一样多,否则就达不到目的(不知道什么目的,没翻译明白),看来为了追上自己喜欢的女孩,
要好好学习数学昂。
思路:
慢慢写吧
就会发现分组的依据是能否被 3 整除,能被整除的都会比之前出现的数字多出一个方案,
则有:
if(n%3==0) ans=n/3*2; else ans=(n/3+1)*2-1;
Code:
#include<stdio.h> int main() { int n; while(scanf("%d",&n)!=EOF) { int ans; if(n%3==0) ans=n/3*2; else ans=(n/3+1)*2-1; printf("%d\n",ans); } return 0; }
相关文章推荐
- 【CodeForces】669A - Little Artem and Presents(找规律)
- CodeForces 669A Little Artem and Presents
- 【CodeForces】[669A]Little Artem and Presents
- 【CodeForces】669A - Little Artem and Presents
- CodeForces 669A Little Artem and Presents
- ACM刷题之Codeforces————Little Artem and Presents
- codeforces 668C - Little Artem and Random Variable
- codeforces 641 C Little Artem and Dance
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition)-A. Little Artem and Presents(模拟)
- 13周练J - Little Artem and Presents【规律】
- CodeForces 641 C.Little Artem and Dance(水~)
- Codeforces Round #348 (div 2) A. Little Artem and Presents
- codeforces 669B B. Little Artem and Grasshopper(水题)
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) A. Little Artem and Presents 水题
- [2-SAT] Codeforces 668E #348 (VK Cup 2016 Round 2, Div. 1 Edition) E. Little Artem and 2-SAT
- ACM刷题之Codeforces———— Little Artem and Grasshopper
- 【codeforce】-#669A-Little Artem and Presents(数学,找规律)
- CodeForces 641 E.Little Artem and Time Machine(BIT+map)
- codeforces 669D D. Little Artem and Dance(乱搞题)
- Codeforces 669B Little Artem and Grasshopper【思维+模拟】