QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#654915#7176. I Flipped The Calendar...Tahmid_cWA 0ms3684kbC++142.5kb2024-10-18 22:51:242024-10-18 22:51:25

Judging History

你现在查看的是最新测评结果

  • [2024-10-18 22:51:25]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3684kb
  • [2024-10-18 22:51:24]
  • 提交

answer

#include <iostream> 
#include <vector>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

bool isLeap(ll y){
    if(y%400==0) return true;
    if(y%100==0) return false;
    if(y%4==0) return true;
    return false;
}
 
ll tt;
void solve(){
    ll arr[] = {31,28,31,30,31,30,31,31,30,31,30,31};
    ll n,pos=3,r=0;
    cin>>n;
    ll diff=n-1970;
    ll leap = diff/4; 
    ll nleap = diff-leap;
    pos+=(leap*30)+(nleap*29);
    pos%=7;
    //dbg(pos);
    forn(i,12){
        // dbg(i);
        // dbg(pos);
        if(i==0){
            if(pos>4){
                r+=6;
                pos+=3;
                pos%=7;
                //dbg(r);
                continue;
            }else{
                r+=5;
                pos+=3;
                pos%=7;
                //dbg(r);
                continue;
            }
        }

        if(i==1){
            if(isLeap(n)){
                r+=5;
                pos+=1;
            }else{
                if(pos==0){
                    r+=4;
                }else{
                    r+=5;
                    //pos++;
                }
            }
            pos%=7;
            //dbg(r);
            continue;
        }
        if(arr[i]==31){
            if(pos>=5){
                r+=6;
            }else{
                r+=5;
            }
            pos+=3;
        }else{
            if(pos>=6){
                r+=6;
            }else{
                r+=5;
            }
            pos+=2;
        }
        pos%=7;
        //dbg(r);
    }
    cout<<r<<ln;
    return;
}
int main()
{
    fast_cin();
    ll t=1;
    tt=1;
    //cin >> t;
    for(int it=1;it<=t;it++) {
        //cout << "Case " << it << ": ";
        solve();
        tt++;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3544kb

input:

2023

output:

63

result:

ok 1 number(s): "63"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

1970

output:

63

result:

ok 1 number(s): "63"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

1971

output:

61

result:

ok 1 number(s): "61"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

1972

output:

63

result:

ok 1 number(s): "63"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

1973

output:

63

result:

ok 1 number(s): "63"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

1974

output:

62

result:

ok 1 number(s): "62"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

1975

output:

62

result:

ok 1 number(s): "62"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

1976

output:

62

result:

ok 1 number(s): "62"

Test #9:

score: -100
Wrong Answer
time: 0ms
memory: 3604kb

input:

1977

output:

61

result:

wrong answer 1st numbers differ - expected: '63', found: '61'