Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

1006题所有的用例都通过了,讨论里的也可以通过,为什么提示wrong answer,附代码

Posted by lish0001 at 2014-12-09 23:04:21
#include <iostream>

#define CONTINUEINPUT(p, e, i, d) ((-1 == p) && (-1 == e) && (-1 == i) && (-1 == d))
#define VALIDINPUT(p, e, i, d) ((0 <= p) && (0 <= e) && (0 <= i) && (0 <= d) \
                             && (365 > p) && (365 > e) && (365 > i) && (365 > d))
#define PERIOD_PHYSICAL     23 
#define PERIOD_EMOTIONAL    28 
#define PERIOD_INTELLECTUAL 33
#define PERIOD_TRIPLE_PEAK  (23 * 28 * 33)

using namespace std;

int main()
{
    int p = 0;
    int e = 0;
    int i = 0;
    int d = 0;
   
    int case_cnt = 0;            // case count

    for (cin >> p >> e >> i >> d; ! CONTINUEINPUT(p, e, i, d); cin >> p >> e >> i >> d)
    {
              
        if (! VALIDINPUT(p, e, i, d)) 
        {
           continue; 
        }
        
        ++case_cnt;                            // increase one by one loop

        int physical = p % PERIOD_PHYSICAL;
        int emotional = e % PERIOD_EMOTIONAL; 
        int intellectual = i % PERIOD_INTELLECTUAL;
       
        for (int TriplePeak = intellectual; TriplePeak < d + PERIOD_TRIPLE_PEAK; TriplePeak += PERIOD_INTELLECTUAL)
        {
            if ( 0 == ((TriplePeak - emotional) % PERIOD_EMOTIONAL) && 0 == ((TriplePeak - physical) % PERIOD_PHYSICAL))
            {
               int future = 0;
               if (TriplePeak <= d)
               {
                   TriplePeak += PERIOD_TRIPLE_PEAK;  
               }

               future = TriplePeak - d;
 
               cout << "Case " << case_cnt <<": the next triple peak occurs in " << future << " days." << endl;
               break; 
            }
        }
    }
    return 0;

}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator