1 条题解

  • 3
    @ 2023-2-11 10:30:56

    一天一天过

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int m, k;
        cin >> m >> k;
        //m: 当前手头的钱
    	//k: 每k元送一元 
    	int ans = 0;//过了多少天 
    	int cnt = 0;//花了多少钱 
    	while(1){
    		//花了一块钱,过了一天 
    		m-=1;
    		ans+=1;
    		cnt+=1;
    		//送钱 
    		if(cnt%k==0)
    			m+=1; 
    		if(m==0)
    			break;    	
    	}
    	cout<<ans<<"\n";
        return 0;
    }
    

    k天k天过

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int m, k;
        cin >> m >> k;
        //m: 当前手头的钱
    	//k: 每k元送一元 
    	int ans = 0;//过了多少天 
    	while(1){
    		//花k块钱,过k天 
    		m-=k;
    		ans+=k;
    		m+=1;
    		if(m<k)
    			break;    	
    	}
    	cout<<ans+m<<"\n";
        return 0;
    }
    
    • 1

    信息

    ID
    1221
    时间
    1000ms
    内存
    256MiB
    难度
    5
    标签
    递交数
    208
    已通过
    83
    上传者