我在写代码时有一行是这样的:
这一行的输出是这样的:
请问是VS出bug了吗(我用的VS)
源代码:
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int N=100;
const int M=N*100;
int t;
double P;
int n;
struct node{
int m;
double p;
}a[N+5];
double dp[M+5];
int cnt[M+5];
void solve()
{
cin>>P>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].m>>a[i].p;
a[i].p=1-a[i].p;
}
for(int i=1;i<=M;i++) dp[i]=-1;
//cout<<dp[0]<<" "<<dp[1]<<"\n";
for(int i=1;i<=n;i++)
{
for(int j=M;j>=a[i].m;j--)
{
if(dp[j-a[i].m]==-1) continue;
//cout<<dp[j]<<" "<<dp[j-a[i].m]+a[i].p<<" ";
if(dp[j]==-1||dp[j]<dp[j-a[i].m]+a[i].p)
{
dp[j]=dp[j-a[i].m]+a[i].p;
cnt[j]=cnt[j-a[i].m]+1;
}
//cout<<cnt[j]<<" "<<j<<" "<<dp[j]<<" ";
}
//cout<<"\n";
}
for(int i=M;i>=0;i--)
{
if(i==4)
{
double res=cnt[i]*1.00-dp[i];
cout<<(res==res)<<" "<<(0.06==0.06)<<" "<<(res==0.06)<<" "<<res<<"\n";
cout<<(res==0.06)<<"\n";
}
if(cnt[i]*1.00-dp[i]>P||dp[i]==-1) continue;
cout<<i<<"\n";
return;
}
cout<<0<<"\n";
}
signed main()
{
cin>>t;
while(t--)
{
solve();
}
return 0;
}