| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
求助: 我的程序是什么问题呢?#include <iostream>
using namespace std;
bool kill(bool *pp,int i, int step)
{
int w = 1, j, jj = -1;
while(w <= i/2){
w++;
for(j = 1;j <= step;j++){
jj++;
if(j == step){
if(jj > i-1)
jj = jj%i;
if(*(pp+jj) == false)
j = j - 1;
*(pp+jj) = false;
}
}
}
for(j = 0;j < i/2;j++){
if(*(pp+j) == false)
return false;
if(j = i/2 -1)
return true;
}
}
int main()
{
int n, i;
while(scanf("%d",&n) != 0){
int j = 0;
bool pp[26] = {1};
i = 2*n;
while(1){
j++;
if(kill(pp, i, j))
break;
}
printf("%d",j);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator