#8773: 為什麼TLE

#### wemee (阿勇)

School : 國立北港高級中學
ID : 4621
2023-09-27 11:01:07
d639. 企鵝村三兄弟penguin -- | From: [60.250.139.121] | Post Date : 2014-04-18 15:51

#include <stdio.h>

int main()
{
unsigned int n,i,j;
unsigned int ary[3] = {1,1,1};
while( scanf("%d", &n)!=EOF ) {
scanf("%d", &n);
if(n<=3){
printf("%d\n", 1);
continue;
}
for(i=0,j=0;i<n-3;i++){
j++;
j %= 3;
ary[j] = ary[0] + ary[1] + ary[2];
ary[j] %= 10007;
}
printf("%d\n", ary[j]);
}
return 0;
}

n=4294967295 比題目預設的還要大

#8774: Re:為什麼TLE

#### wemee (阿勇)

School : 國立北港高級中學
ID : 4621
2023-09-27 11:01:07
d639. 企鵝村三兄弟penguin -- | From: [60.250.139.121] | Post Date : 2014-04-18 15:54

#include <stdio.h>

int main()
{
unsigned int n,i,j;
unsigned int ary[3] = {1,1,1};
while( scanf("%d", &n)!=EOF ) {
if(n<=3){
printf("%d\n", 1);
continue;
}
for(i=0,j=0;i<n-3;i++){
j++;
j %= 3;
ary[j] = ary[0] + ary[1] + ary[2];
ary[j] %= 10007;
}
printf("%d\n", ary[j]);
}
return 0;
}

#10219: Re:為什麼TLE

#### tommy71213 (心上一個敢)

School : 國立屏東高級中學
ID : 51114
2023-06-18 03:58:49
d639. 企鵝村三兄弟penguin -- | From: [114.35.144.253] | Post Date : 2015-09-09 10:57

#include

int main()
{
unsigned int n,i,j;
unsigned int ary[3] = {1,1,1};
while( scanf("%d", &n)!=EOF ) {
if(n<=3){
printf("%d\n", 1);
continue;
}
for(i=0,j=0;i<n-3;i++){
j++;
j %= 3;
ary[j] = ary[0] + ary[1] + ary[2];
ary[j] %= 10007;
}
printf("%d\n", ary[j]);
}
return 0;
}

ZeroJudge Forum