if

if()
else if()
else
有的时候会莫名其妙进前一条if?

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long c,n,x,a,b;
    cin>>c>>n;
    x=n/c;
    if(x>=2)
    {
        b=x*c;
        a=(x-1)*c;
        cout<<a*b<<endl;
    }
    else if(x=1)
        cout<<c*c<<endl;
    else
       cout<<-1<<endl;
    return 0;
}

输入:100 1
输出:10000

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务