A1083 | [COCI-2006_2007-contest5]#2 IVANA
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Even though she saw Zvonko steal Mirko's microprocessor in the second task, Mirko's sister Ivana did not tell Mirko because she likes Zvonko. She suggested to him that they go see a movie together so that she would "forget" about the incident.
Zvonko does not care much for girls because they take away precious time he usually spends practicing his math-fu. He suggested that the two of them play a game and, if Ivana wins, they will go see a movie together. Ivana agreed, being good at jump rope and she sometimes even kicks a football around with her two brothers.
Zvonko laid N positive integers in a circle on the floor and explained the rules:
• The first player takes any number.
• The second player takes either of the two numbers adjacent to the one the first player took.
• The next player takes a number adjacent to any of the numbers taken so far, and so on until they run out of numbers. The player to take more odd numbers (not divisible by 2) wins.
Zvonko plays optimally; he always looks for a strategy that leads to certain victory or a draw. Zvonko does not know how well Ivana plays. Being a true cavalier, he let Ivana have the first move.
But Ivana only cares about sitting next to Zvonko in front of the big screen so she seeks help playing.
Write a program that finds how many different first moves Ivana can make, so that she has a chance of winning afterwards.
Zvonko does not care much for girls because they take away precious time he usually spends practicing his math-fu. He suggested that the two of them play a game and, if Ivana wins, they will go see a movie together. Ivana agreed, being good at jump rope and she sometimes even kicks a football around with her two brothers.
Zvonko laid N positive integers in a circle on the floor and explained the rules:
• The first player takes any number.
• The second player takes either of the two numbers adjacent to the one the first player took.
• The next player takes a number adjacent to any of the numbers taken so far, and so on until they run out of numbers. The player to take more odd numbers (not divisible by 2) wins.
Zvonko plays optimally; he always looks for a strategy that leads to certain victory or a draw. Zvonko does not know how well Ivana plays. Being a true cavalier, he let Ivana have the first move.
But Ivana only cares about sitting next to Zvonko in front of the big screen so she seeks help playing.
Write a program that finds how many different first moves Ivana can make, so that she has a chance of winning afterwards.
输入格式
The first line of input contains an integer N (1 ≤ N ≤ 100), how many numbers there are in the circle.
The second line contains N integers separated by single spaces. All numbers will be between 1 and 1000 (inclusive). No two numbers will be the same.
The second line contains N integers separated by single spaces. All numbers will be between 1 and 1000 (inclusive). No two numbers will be the same.
输出格式
Output the desired number on a single line.
输入输出样例
输入 #1
3 3 1 5
输出 #1
3
输入 #2
4 1 2 3 4
输出 #2
2
输入 #3
8 4 10 5 2 9 8 1 7
输出 #3
5
First example: Whichever number Ivana takes first, she'll end up with two odd numbers, and Zvonko
will have gotten only one.
Second example: If Ivana takes one of the even numbers, Zvonko will take one of the odd numbers
and ensure a draw. If she takes an odd number, Zvonko will have to take an even number and then
lose because Ivana can take the other odd number.
will have gotten only one.
Second example: If Ivana takes one of the even numbers, Zvonko will take one of the odd numbers
and ensure a draw. If she takes an odd number, Zvonko will have to take an even number and then
lose because Ivana can take the other odd number.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted