URAL 2048 Histroy

Source: Internet
Author: User
Tags define local

Because the Almanac is a 400-year cycle, it is handed out for a year, and then the case of a cyclic section is recursively processed. For questioning, it would be nice to ask for something like a prefix.

When writing, pay attention to the definition of variables ... Otherwise wa to cry ... I am 6 for the Week 5, 1900 is the first year, so B,a minus 1900 to add one.

#include <cstdio>#include<cstring>BOOLIsleapyear (inty) {   if(y% -){      return! (y&3); }   Else {      return! (y% -); }}               //1 3 5 7 8intDays[] = {-1, to, -, to, -, to, -, to, to, -, to, -, to};//6 7 1 2 3 4 5intcnt1[7];//January-Februaryintcnt2[7];//after Februaryintcnt[7];//1900voidfirstyear () {intv =0;  for(intm =1; M <=2; m++) {Cnt1[v]++; V= (V+days[m])%7; }   for(intm =3; M <= A; m++) {Cnt2[v]++; V= (V+days[m])%7; }   for(inti =0; I <7; i++) {Cnt[i]= cnt1[i]+Cnt2[i]; }}intcnt400[401][ -];intcntcur[7];voidCircle () {firstyear (); intmov =0; inti =1;//1900    for(inty =1900; Y <2300; y++,i++) {//+mov1 2->last 1memset (Cntcur,0,sizeof(cntcur)); if(Isleapyear (y)) { for(inti =0; I <7; i++)//not affected until FebruaryCntcur[i] + = cnt1[(i-mov+7)%7]; MOV= (mov +1)%7;//relative to the previous year          for(inti =0; I <7; i++) Cntcur[i]+ = cnt2[(i-mov+7)%7]; }      Else {          for(inti =0; I <7; i++) Cntcur[i]+ = cnt[(i-mov+7)%7]; } mov= (mov +1)%7;//365%7 =1       for(intj =0; J < -; J + +) {Cnt400[i][j]= cnt400[i-1][j]; } cnt400[i][cntcur[6]]++; }}intans[ -];//#define LOCALintMain () {#ifdef local freopen ("Data.txt","W", stdout);#endif //Local   intb;   Circle (); scanf ("%d%d",&a,&c); B++; a++; intA = (A-1-1900)% -; intNa = (A-1-1900)/ -; intb = (Beta-1900)% -; intNB = (b-1900)/ -;  for(inti =0; I < -; i++) {Ans[i]+ = (Nb-na) *cnt400[ -][i] + cnt400[b][i]-Cnt400[a][i]; }     for(inti =0; I < -; i++) printf ("%d:%d\n", I,ans[i]); return 0;}

URAL 2048 Histroy

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.