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; struct User{ int id; int period; int time; }; User user[1000]; int cmp(const void *e1,const void *e2) { if(((User*)e1)->time<((User*)e2)->time) return -1; else if(((User*)e1)->time>((User*)e2)->time) return 1; else if(((User*)e1)->id<((User*)e2)->id) return -1; else return 1; } int main() { char r[10]; int i=0,k,time; while(scanf("%s",r)&&r[0]!='#') { scanf("%d %d",&user[i].id,&user[i].period); user[i].time=user[i].period; i++; } scanf("%d",&k); int n=i; qsort(user,n,sizeof(User),cmp); time=user[0].time; while(k) { for(i=0;i<n;i++) if(time%user[i].time==0) { printf("%d\n",user[i].id),k--; if(k==0) break; } time++; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator