Poj 1006 biorhythms number theory-(Sun Tzu's theorem)

Source: Internet
Author: User

Question address: http://poj.org/problem? Id = 1006 & lang = default & change = true

This is the question of a deformed Sun Tzu's theorem, which is used directly by formulas.

CodeAs follows:

 

# Include <iostream> # include <cstdio> # include <cstdlib> # include <cmath> # include <cstring> # include <string> # include <algorithm> # include <vector> # include <set> # include <map> # include <queue> using namespace STD; /* freopen ("input.txt", "r", stdin); // read data freopen ("output.txt", "W", stdout ); // comment out this sentence and output it to the console */INT main () {int N, LCM, A, B, C, D, casei = 0; int K1, K2, K3; while (CIN> A> B> C> D & (A + B + C + D )! =-4) {LCM = 21252; // lcm (5544, 33); k1 =; // K1 % 28 = k1 % 33 = 0, K1 % 23 = 1; k2 = 14421; // K2 % 23 = k2 % 33 = 0, K2 % 28 = 1; K3 = 1288; // K3 % 28 = K3 % 23 = 0, k3 % 33 = 1; n = (K1 * A + K2 * B + K3 * c-d + LCM) % LCM; If (n = 0) n = LCM; printf ("case % d: The next Triple peak occurs in % d days. \ n ", ++ casei, n);} return 0 ;}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.