1 solutions

  • 0
    @ 2026-11-29 19:30:44

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        long long n,m,x,cnt = 0,ans = 0;
        cin >> n >> m >> x;
        
        int L = 5 * m / __gcd(5ll,m);
        
        int id = 1;
        for (int i = 1;i<=L;i++){
            if (id == x && i % 5 !=0){
                cnt ++;
            }
            id = id % m + 1;
        }
        ans = n / L * cnt;	//周期数量 * 每个周期的数量
    	
    	int tmp = n%L;
    	for (int i = 1;i<=tmp;i++){		//计算剩余 
    		if (id == x && i % 5 !=0){
                ans ++;
            }
            id = id % m + 1;
    	}	 
        cout << ans;
        
        return 0;
    }
    
    • 1

    Information

    ID
    453
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By