#include<iostream> #include<algorithm> usingnamespace std; constint N = 1e6 + 110; int dp[N]; intmain(){ int n, m; cin >> n >> m; dp[0] = 1; if(n > m) swap(n, m); int ans = 0; for(int i = n; i < n * m; i++){ if(dp[i - n] || (i >= m && dp[i - m])){ dp[i] = true; } else ans = i; } cout << ans << endl; return0; }
饮料换购
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include<iostream> usingnamespace std;
intmain(){ int n; cin >> n; int ans = n; while(n >= 3){ n -= 3; n += 1; ans++; } cout << ans << endl; return0; }