感觉自己要进场。
#include <bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin >> T;
while (T--)
{
long long n, k,ans=0;
cin>>n>>k;
if (k==0)
{
cout<<1<<endl;
continue;
}
for(long long q=n/(k+1);q*k<=n;q++)
{
long long r=n-(q*k);
if(r<0) break;
if (r<q)
{
ans++;
}
}
cout<<ans<<endl;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int f(const string &S, int &pos, int x)
{
int result=0;
while (pos<S.length() and isdigit(S[pos]))
{
result=result*10+(S[pos]-'0');
pos++;
}
if (pos == S.length() || S[pos] != 'x')
{
return result;
}//算尽了
//嵌套了下一个三目
bool greater=(S[pos + 1] == '>');
pos += 2;
int con = 0;
while (isdigit(S[pos]))
{
con=con*10+(S[pos]-'0');
pos++;
}
pos++;
int truee = f(S, pos, x);
pos++;
int falsee = f(S, pos, x);
if ((greater and x > con) or (!greater and x < con))
{
return truee;
}
else
{
return falsee;
}
}
int main()
{
int m,q;
cin >>m>>q;
string S;
cin>>S;
while(q--)
{
int x;
cin>>x;
int pos=0;
cout<<f(S,pos,x)<<endl;
}
return 0;
}