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

Re:是否triple peak可能出现在三个给出日期之前?

Posted by C0400104048 at 2004-04-05 19:35:21 on Problem 1006
In Reply To:Re:是否triple peak可能出现在三个给出日期之前? Posted by:ale at 2004-04-04 20:49:01
#include <iostream>
#include <vector>
using namespace std;

int main()
{
   vector<int> days;
   int a, b, c, d, x, y, i = 0;
   while(++i){//!start from 1 ,and at last will add another 1 to i
      cin >> a >> b >> c >> d;
      if(a > 365 || a < 0 ||
         b > 365 || b < 0 ||
         c > 365 || c < 0 ||
         d > 365 || d < 0 )
         break;
      x = 0;
      y = 0;
————————————————————————————
      while(a-23>0)a=a-23;
————————————————————————————
      while(((23 * x - b + a) % 28))
         ++x;
      while(((23 * 28 * y + 23 * x - c + a) % 33))
         ++y;  
      if((23 * 28 * y + 23 * x - d + a) > 0)
          days.push_back(23 * 28 * y + 23 * x - d + a);
          else
             days.push_back(23 * 28 * y + 23 * x - d + a + 21252);
   }
   for(int j = 0; j < i - 1; j++)
      cout << "Case " << j + 1 << ": the next triple peak occurs in "
           << days[j] << " days." << endl;
}

我加了一行,过了。给的a不一定是本年第一个PHY_PEAK值,所以不能肯定THREE_PEAK值一定比它大。

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