| ||||||||||
| 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 | |||||||||
我真的没辙了。无论是同一输出还是单个输出,输出结果包含不包含边界情况我都测试过了,底下都对了,但是提交了却没有一个通过的。真是郁闷阿~!各位帮忙看看到底怎么错了?我看我的算法还算是比较快的呢,结果还是这样,郁闷阿~~多谢了~!
另: 我从来没有写过c的程序,所以不太规范,请多多见谅~
# include <stdio.h>
# include <stdlib.h>
# define LEN sizeof(struct Node)
struct Node {
int p,e,i,d,n;
struct Node * next;
};
struct Node * head;
int seat[21253]={0};
int Count(struct Node * p) {
int i,tmp=0,min=21252;
for (i=1;i<=645;i++) {
tmp = 33 * i + p->i - p->d;
if ((tmp+p->d-p->p) % 23 == 0 && (tmp+p->d-p->e) % 28 == 0 && tmp>0 && tmp<=min) {
min = tmp;
break;
}
}
p->n = min;
return 1;
}
int main() {
int p=0,e=0,i=0,d=0;
struct Node * ins, * current;
head = malloc(LEN);
head->next = NULL;
ins = current = head;
while (p!=-1 && e!=-1 && i!=-1 && d!=-1) {
scanf("%d%d%d%d",&p,&e,&i,&d);
ins = malloc(LEN);
current->next = ins;
ins->next = NULL;
ins->p = p;
ins->e = e;
ins->i = i;
ins->d = d;
ins->n = 21252;
current = ins;
Count(current);
}
current = head->next; i=0;
while (current->next!=NULL) {
printf("Case %d: the next triple peak occurs in %d days.\n",++i,current->n);
current = current->next;
}
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator