本文主要是介绍NYOJ-64 鸡兔同笼,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
source link
1.tips
解方程,判断下解是不是正整数
2.code
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;int main()
{int t;int n,m;cin>>t;while(t--){cin>>n>>m;int x=(m-2*n)/2;if((m-2*n)%2 || (m-2*n)<=0)cout<<"No answer"<<endl;elsecout<<n-x<<" "<<x<<endl;}return 0;
}
这篇关于NYOJ-64 鸡兔同笼的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!