样例过不了,求调

题目总版

hz_Glmc @ 2025-01-11 13:41:24

#include<bits/stdc++.h>

using namespace std;

int main() {
    int a,b,day = 0;
    cin >> a >> b;
    for(int i=0;i<=b;i++){
        day += a;
    }
    if(day % 7 == 0){
        puts("Sunday");
    }else if(day % 7 == 1){
        puts("Monday");
    }else if(day % 7 == 2){
        puts("Tuesday");
    }else if(day % 7 == 3){
        puts("Wednesday");
    }else if(day % 7 == 4){
        puts("Thursday");
    }else if(day % 7 == 5){
        puts("Friday");
    }else{
        puts("Saturday");
    }
    return 0;
}

B2074


by XsIeEiKcEk @ 2025-01-11 14:18:57

for(int i=1;i<=b;i++)

by XsIeEiKcEk @ 2025-01-11 14:19:33

第八行


by wangshengchen @ 2025-01-11 14:19:56

@hz_Glmc 可以参考一下我的。

#include<bits/stdc++.h>
using namespace std;
int main(){
    string d[10]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
    int n,m,a=1;
    cin>>n>>m;
    n%=7;
    for(int i=1;i<=m;i++) a*=n,a%=7;
    cout<<d[a];
    return 0;
}

求关。


by Richey808 @ 2025-01-12 15:45:21

直接暴力,7个if完事

#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
    int a,b,ans=1;
    cin>>a>>b;
    for(int i=1;i<=b;i++)
    {
        ans*=a;
        ans%=7;
    }
    int c=ans%7;
    if(c==0)cout<<"Sunday";
    if(c==1)cout<<"Monday";
    if(c==2)cout<<"Tuesday";
    if(c==3)cout<<"Wednesday";
    if(c==4)cout<<"Thursday";
    if(c==5)cout<<"Friday";
    if(c==6)cout<<"Saturday";
    return 0;
}

|