ccf-201712-2

ccf-201712-2

#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main() {
    int n,num;
    cin>>n>>num;
    int child[n+1];
    memset(child,0,sizeof(child));
    int sum=0;
    while(1) {
        int j=0,end;
        for(int i=1; i<n+1; i++) {
            if(child[i]==0) {
                sum++;
                if(sum%num==0||sum%10==num) {
                    child[i]=1;
                    if(j==0&&i==n){
                        j++;
                        end=i;
                    }
                } else {
                    j++;
                    end=i;
                }
            }
        }
        if(j==1) {
            cout<<end;
            break;
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_36792042/article/details/82381524
今日推荐