A 清楚姐姐学信息论
进制是效率最高的进制,越靠近e进制效率越高,所以除 (2 3),(3 2) 外,都是小的进制更优。
a , b = map(int , input().split())
if a == 3 or b == 3:
print(3)
else:
print(min(a , b))
C 清楚姐姐学01背包(Easy Version)
把除了第i个物品以外的物品打一个01背包,判断第i个物品是否必须取(取这个物品后答案更优)即可。
#include
#include
using namespace std;
typedef long long ll;
const int N = 110;
ll v[N] , w[N];
ll f[N];
int n , m;
int main()
{
cin >> n >> m;
for(int i = 1;i <= n;i ++)
cin >> v[i] >> w[i];
for(int k = 1;k <= n;k ++)
{
memset(f , 0 , sizeof f);
for(int i = 1;i <= n;i ++)
{
if(i == k) continue;
for(int j = m;j >= v[i];j --)
f[j] = max(f[j] , f[j - v[i]] + w[i]);
}
ll res = f[m] - f[m - v[k]] - w[k] + 1;
if(res < 0) cout << 0 << endl;
else cout << res << endl;
}
return 0;
}
E 清楚姐姐打怪升级
怪物血量>伤害&&攻击间隔*恢复>=伤害 => 杀不死
注意一下第一次攻击的时间记得加上
#include
using namespace std;
int main()
{
long long n, t, a, rr, rrr, res = 0, flag = 0, h, v;
cin >> n >> t >> a;
for (int i = 0; i < n; i++)
{
cin >> h >> v;
res += t, h -= a;
if (h <= 0) continue;
if (t * v >= a)
{
cout << "-1";
return 0;
}
else
{
res += (h / (a - t * v))* t;
if (h % (a - t * v)) res += t;
}
}
cout << res - t + 1;
}
L清楚姐姐的三角形I
三角形三条边满足任意两边之和大于第三边,任意两边之差小于第三边,la,lb,lc都是正整数
#include
using namespace std;
typedef long long ll;
double va , vb , vc;
double la , lb , lc;
int t;
bool check()
{
if(la != (ll)la || lb != (ll)lb || lc != (ll)lc) return false;
if(la <= 0 || lb <= 0 || lc <= 0) return false;
if(la + lb <= lc || la + lc <= lb || lb + lc <= la) return false;
if(la - lb >= lc || la - lc >= lb || lb - lc >= la) return false;
if(lb - la >= lc || lc - la >= lb || lc - lb >= la) return false;
return true;
}
int main()
{
cin >> t;
while(t --)
{
cin >> va >> vb >> vc;
la = (vb + vc - va) / 2;
lb = (vc + va - vb) / 2;
lc = (vb + va - vc) / 2;
if(check())
{
puts("YES");
cout << (ll)la << " " << (ll)lb << " " << (ll)lc << endl;
}
else puts("NO");
}
return 0;
}
M 清楚姐姐的三角形II
112循环即可
#include
using namespace std;
const int N = 1e5 + 10;
int n;
int f[N];
int main()
{
cin >> n;
int t = n % 3;
for(int i = 1;i <= n / 3;i ++)
cout << "1 1 2 ";
if(t == 1) cout << "1";
else if(t == 2) cout << "1 1";
return 0;
}