1795 The least one【素数打表】

The least one

Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 423    Accepted Submission(s): 149


Problem Description
  In the RPG game “go back ice age”(I decide to develop the game after my undergraduate education), all heros have their own respected value, and the skill of killing monsters is defined as the following rule: one hero can kill the monstrers whose respected values are smaller then himself and the two respected values has none common factor but 1, so the skill is the same as the number of the monsters he can kill. Now each kind of value of the monsters come. And your hero have to kill at least M ones. To minimize the damage of the battle, you should dispatch a hero with minimal respected value. Which hero will you dispatch ? There are Q battles, in each battle, for i from 1 to Q, and your hero should kill Mi ones at least. You have all kind of heros with different respected values, and the values(heros’ and monsters’) are positive.
 

Input
  The first line has one integer Q, then Q lines follow. In the Q lines there is an integer Mi, 0<Q<=1000000, 0<Mi<=10000.
 

Output
  For each case, there are Q results, in each result, you should output the value of the hero you will dispatch to complete the task.
 

Sample Input
  
  
2 3 7
 

Sample Output
  
  
5 11

这个题比较简单......


最重要的是读懂题意,题意说的是.....


给你一个数,代表有一群编号为 1~m  的怪物,需要你派遣一个人去杀怪物,而且杀怪物的数量不能少于给出的怪物数量,规定的屠杀怪兽的规则是人的能力要高于怪兽的能力,且怪兽和人的能力值不能有除 1 外的公因子!.....


这样一分析,就发现问题变简单了............就是找到大于这个数的最小素数!!!


题解:

先打个素数表,然后就从这个元素开始往更大的方向开始查找.........

找到后就直接输出........


#include<stdio.h>
int x[1000005];
int main()
{
    int t,n,i,j;
    x[1]=0;
    for(i=2;i<1000005/i;++i)//打表........
    {
        if(x[i]==0)
        {
            for(j=2;j<1000005/i;++j)
            {
                x[i*j]=1;
            }
        }    
    }
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        ++n;
        while(x[n]!=0)//查找.......
        {
        	++n;
	}
        printf("%d\n",n);//输出..........
    }
    return 0;
}




Given the grid below for the game of ACSL Patolli, utilize the following rules to play the game. All rules must be applied in the sequential order listed. 1 . There are 2 players. Each player has 3 markers. 2. The markers move according to the roll of a die (1 – 6). 3. Markers move in numerical order around the grid. 4. If, on a die roll, a marker lands on an occupied location, then that marker loses its turn and remains at its previous location. 5. A marker can jump over another marker on its way to finish its move. 6. A marker finishes its way around the grid when it lands on location 52. It is then removed from the board. A move can’t take a marker beyond location 52. If it does, the marker remains at its previous location. 7. If, on a die roll, a marker lands on an unoccupied location that is a prime number, the marker then moves six locations forward. However, it stops immediately before any occupied location. 8. If, on a die roll, a marker lands on an unoccupied location that is a perfect square greater than 4, the marker then moves 6 locations backwards. However, it stops immediately before any occupied location. 9. If, on a die roll, a marker lands on an unoccupied location that is neither a prime number nor a perfect square, then determine if the marker made at least one horizontal move followed by at least one vertical move (such as going from 6 to 8, 11 to 13, 26 to 28 … but not 2 to 4 or 30 to 32). In that case, the marker can only land on a location on its path that is a multiple of the die roll value even if it moves a smaller distance than the die roll value. However, if all the locations in its path that are multiples are occupied, then the marker does not move from its current location. The rules listed in #7 and #8 do not apply when using #9.
03-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值