N ants are in a circular race. The length of the race is 1000 meters and ant number i is initially Vi meters far from starting point (point 0) of the race in clockwise order. All the ants walk with a speed of 0.1 meters per second, some of them walk in clockwise order, some in counter clockwise order. When two ants meet at a point, they say "Hi" to each other and both of them change their direction of walking to the opposite direction. This process is timeless, meaning they say "Hi" and change their direction in 0 seconds.
You are given the initial position of ants, you don't know their initial directions but you want to know how many times do they say "Hi" to each other after 1000000006 ( 10^9+6 seconds ). You need to find the initial walking direction of ants such that, c1+c2+c3+...+cn is maximized, where ci is the number of times ant number i say "Hi". Print this maximum value.
Input:
The first line of the input contains an integer N, the number of ants. N is not greater than 100.
Next line contains n numbers V1 , V2 , ... , VN. All Vi are non negative integers less than 1000. All Vi are distinct.
Output:
On the only line of the output print an integer being the answer to the test.
In the example there are two ants, In case their direction is the same, they will never say hi to each other, in the other case they will say "Hi" to each other in times 2500, 7500,12500, ... , 999999750. so the result for an Ant would be (999997500 - 2500)/5000+1 = 200000. Hence the answer is 200000*2 = 400000.
以上就是题目了:
#include <stdio.h>
int main(int argc, char * argv[])
{
int time = 1000000006;
int single_circle_time = 10000;
int ants_number;
int hit;
int flag;
scanf("%d", &ants_number);
if(ants_number & 1){
flag = 0;
}
else{
flag = 1;
}
if(flag)
hit = time/single_circle_time * (ants_number/2 * 2 * ants_number/2 * 2);
else
hit = time/single_circle_time * (ants_number/2 * 2 * (ants_number/2 + 1) * 2);
printf("%d", hit);
return 0;
}
代码。。。OK了。。。
本文探讨了一个关于蚂蚁在环形赛道上的行走模式和相遇情况的问题,重点是计算在特定时间内蚂蚁互相问候的次数。通过输入蚂蚁的数量和初始位置,读者可以了解如何优化蚂蚁的行走方向以最大化它们的问候次数。
480

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



