ZJANS

b860. 獨角蟲進化計算器

Medium Last Update: 2026/01/01
數學

解法一

✅ 完整代碼

評分結果(參考) : AC (4ms, 336KB)

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int c, w;
    cin >> c >> w;
    
    int ans = 0;
    while(w>0){
        if(c >= 12){
            c -= 10;
            w--;
            ans++;
        }
        else{
            w -= (12-c);
            c = 12;
        }
    }
    cout << ans;
    
    return 0;
}

解法二、數學

✅ 完整代碼

評分結果(參考) : AC (2ms, 344KB)

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int c, w;
    cin >> c >> w;
    cout << min(w, (c+w-2)/11);
    
    return 0;
}