题解:P16907 「MierOI R2」雨之城
TchongS1010C · · 题解
一道入门题。
怎么做
我们可以发现
注意:要是 inf 。
#include <bits/stdc++.h>
using namespace std ;
double t , n , m , s[15] , a[15] ;
int main()
{
cin >> t ;
while(t --)
{
cin >> n >> m ;
for(int i = 1 ; i <= n ; i ++)
{
cin >> a[i] ;
}
for(int i = 1 ; i <= n ; i ++)
{
cin >> s[i] ;
if(0.3 * a[i] >= m)
{
cout << "inf " ;
continue ;
}
double ans = (250 - s[i]) / 250 * a[i] ;
if(ans < m)
{
cout << "0 " ;
continue ;
}
for(int j = 1 ; j <= 50000 ; j ++)
{
ans -= 50 ;
if(ans < m)
{
cout << j << " " ;
break ;
}
if(ans == m)
{
cout << j + 1 << " " ;
break ;
}
}
}
cout << "\n" ;
}
return 0 ;
}
数学推导不会,麻烦在评论区说一下。