++++++++++++++++++++++++++++++++++++++++++++1076+++++++++++++++++++++++++++++++++++++++++++++++++++

Source: Internet
Author: User

I also have no language, think not to open where wrong, first put here wait for a period of time not confused and then go to see. or show the master. The error code is attached below

#include <stdio.h>voidLeap ();inta[ $];intMain () {intYear,r,w,e,q,t,i,s,b,d,c;    Leap (); scanf ("%d",&t);  while(t--) {scanf ("%d%d",&year,&d); if((year%4==0&&year% -!=0)|| year% -==0) R=1; ElseR=0; W=d% the; E=d/ the; C=year/ -; b=year% -;  for(i=0;i< Max; i++)        {            if(a[i+1]>b&&a[i]<b| | a[i]==b) {Q=i;  Break; }} s= -* (c+e) +a[w+q-R]; printf ("%d\n", s); }    return 0;}voidLeap () {inti,w=0;  for(i=0;i< the; i++)    {        if(i%4==0&&i% -!=0|| i% -==0) {a[w++]=i; }    }}

The correct code is attached below

//The idea is simple, but it's also a good idea. But the time complexity is higher. The previous time complexity is lower,//But the comparison is not right, also do not know how.#include <stdio.h>intMain () {intN; scanf ("%d",&N);  while(n--)    {        intA,b,i=0, num; scanf ("%d%d",&a,&b);  while(b!=0) {num=a+i; I++; if((num%4==0&&num% -!=0)|| num% -==0) {b--; }} printf ("%d\n", num); }    return 0;}

++++++++++++++++++++++++++++++++++++++++++++1076+++++++++++++++++++++++++++++++++++++++++++++++++++

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.